Skip to content

Instantly share code, notes, and snippets.

View tsegismont's full-sized avatar

Thomas Segismont tsegismont

View GitHub Profile
@tsegismont
tsegismont / MyCollectdEventHandler.java
Created November 4, 2014 22:06
netty-collectd example event handler
import static io.netty.channel.ChannelHandler.Sharable;
import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.SimpleChannelInboundHandler;
import org.rhq.metrics.netty.collectd.events.Event;
@Sharable
public class MyCollectdEventHandler extends SimpleChannelInboundHandler<Event> {
@Override
@tsegismont
tsegismont / NettyCollectdBootstrap.java
Created November 4, 2014 22:05
netty-collectd bootstrap
group = new NioEventLoopGroup();
bootstrap = new Bootstrap();
bootstrap.group(group).channel(NioDatagramChannel.class).handler(new ChannelInitializer<Channel>() {
@Override
protected void initChannel(Channel channel) throws Exception {
ChannelPipeline pipeline = channel.pipeline();
pipeline.addLast(new CollectdPartsDecoder()); // Add CollectdPartsDecoder first
pipeline.addLast(new CollectdEventsDecoder()); // Then CollectdEventsDecoder
pipeline.addLast(new MyCollectdEventHandler()); // Consume events in your own handler
}
@tsegismont
tsegismont / pom.xml
Created November 4, 2014 22:02
netty-collectd dependency
<dependency>
<groupId>org.rhq.metrics.netty</groupId>
<artifactId>netty-collectd</artifactId>
<version>0.1-SNAPSHOT</version>
</dependency>
@tsegismont
tsegismont / rhq-plugin.xml
Created March 18, 2014 13:49
mbeans-on-as7-plugin sample plugin descriptor
<plugin
name="MyappMBeansPlugin"
displayName="Myapp MBeans Plugin"
package="com.myapp.services.plugin"
xmlns="urn:xmlns:rhq-plugin"
xmlns:c="urn:xmlns:rhq-configuration">
<depends plugin="JBossAS7" useClasses="true"/>
<service name="Myapp Services"
@tsegismont
tsegismont / pom.xml
Last active August 29, 2015 13:57
mbeans-on-as7-plugin sample POM
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>mbeans-on-as7-plugin</groupId>
<artifactId>mbeans-on-as7-plugin</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>rhq-agent-plugin</packaging>
@tsegismont
tsegismont / rhq-plugin.xml
Created March 18, 2014 10:26
Depend on and use classes of AS7Plugin
<depends plugin="JBossAS7" useClasses="true"/>
@tsegismont
tsegismont / bundles.js
Last active December 25, 2015 04:38
createBundleVersion
/**
* A simple function to create a new bundle version from a zip file containing
* the bundle.
*
* @param pathToBundleZipFile the path to the bundle on the local file system
*
* @return an instance of BundleVersion class describing what's been created on
* the RHQ server.
*/
function createBundleVersion(pathToBundleZipFile) {
@tsegismont
tsegismont / ScriptUtil.java
Created October 10, 2013 13:18
org.rhq.bindings.util.ScriptUtil#uploadContent
public String uploadContent(String filename) {
if (remoteClient == null) {
throw new IllegalStateException("The uploadContent method requires a connection to the RHQ server.");
}
ContentUploader contentUploader = new ContentUploader(remoteClient.getProxy(ContentManagerRemote.class));
return contentUploader.upload(filename);
}
@tsegismont
tsegismont / ContentManagerRemote.java
Created October 10, 2013 13:11
ContentManagerRemote
/**
* Creates a temporary file for fragmented content upload.
*
* @return a temporary file handle
*/
String createTemporaryContentHandle();
/**
* Saves the fragment in the temporary file denoted by <code>temporaryContentHandle</code>.
*
@tsegismont
tsegismont / createPackageBackedResourceViaContentHandle.js
Last active December 25, 2015 04:29
createPackageBackedResourceViaContentHandle
var contentHandle = scriptUtil.uploadContent(pathName);
ResourceFactoryManager.createPackageBackedResourceViaContentHandle(
parentResourceId,
applicationTypeId,
packageName,
pluginConfiguration,
packageName,
version,
null, // architectureId