Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
 // Copyright (c) P. Taylor Goetz (ptgoetz@gmail.com)
 
 package backtype.storm.contrib.signals.client;
 
 
 import  org.apache.zookeeper.data.Stat;
 import  org.slf4j.Logger;
 import  org.slf4j.LoggerFactory;
import  com.netflix.curator.framework.CuratorFramework;
import  com.netflix.curator.framework.CuratorFrameworkFactory;
import  com.netflix.curator.retry.RetryOneTime;
public class SignalClient {
    private static final Logger LOG = LoggerFactory.getLogger(SignalClient.class);
    private CuratorFramework client = null;
    private String name;
    public SignalClient(String zkConnectStringString name) {
        this. = name;
        try {
            this. = CuratorFrameworkFactory.builder().namespace("storm-signals").connectString(zkConnectString)
                    .retryPolicy(new RetryOneTime(500)).build();
        } catch (IOException e) {
            .error("Error creating zookeeper client."e);
        }
        .debug("created Curator client");
    }
    public void start() {
        this..start();
    }
    public void close() {
        this..close();
    }
    public void send(byte[] signalthrows Exception {
        Stat stat = this..checkExists().forPath(this.);
        if (stat == null) {
            String path = this..create().creatingParentsIfNeeded().forPath(this.);
            .info("Created: " + path);
        }
        this..setData().forPath(this.signal);
    }

    

Parameters:
args
    public static void main(String[] argsthrows Exception {
        SignalClient sc = new SignalClient("localhost:2000""test-signal-spout");
        sc.start();
        try {
            sc.send("Hello Signal Spout!".getBytes());
        } finally {
            sc.close();
        }
    }
New to GrepCode? Check out our FAQ X