本文整理汇总了Java中backtype.storm.messaging.IConnection类的典型用法代码示例。如果您正苦于以下问题:Java IConnection类的具体用法?Java IConnection怎么用?Java IConnection使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
IConnection类属于backtype.storm.messaging包,在下文中一共展示了IConnection类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: zmq_bind
import backtype.storm.messaging.IConnection; //导入依赖的package包/类
protected IConnection zmq_bind(boolean distributeZmq, int port) {
String url = null;
if (distributeZmq) {
if (ipc) {
url = "ipc://" + port + ".ipc";
} else {
url = "tcp://*:" + port;
}
} else {
// virtportZmq will be true
url = "inproc://" + port;
}
Socket socket = ZeroMq.socket(context, ZeroMq.pull);
ZeroMq.bind(socket, url);
ZeroMq.set_hwm(socket, maxQueueMsg);
// ZeroMq.subscribe(socket);
LOG.info("Create zmq receiver {}", url);
return new ZMQRecvConnection(socket);
}
开发者ID:zhangjunfang,项目名称:jstorm-0.9.6.3-,代码行数:24,代码来源:MQContext.java
示例2: zmq_connect
import backtype.storm.messaging.IConnection; //导入依赖的package包/类
protected IConnection zmq_connect(boolean distributeZmq, String host, int port) {
String url = null;
if (distributeZmq) {
if (ipc) {
url = "ipc://" + port + ".ipc";
} else {
url = "tcp://" + host + ":" + port;
}
} else {
// virtportZmq will be true
url = "inproc://" + port;
}
Socket socket = ZeroMq.socket(context, ZeroMq.push);
socket = ZeroMq.set_linger(socket, linger_ms);
socket = ZeroMq.connect(socket, url);
ZeroMq.set_hwm(socket, maxQueueMsg);
LOG.info("Create zmq sender {}", url);
return new ZMQSendConnection(socket, host, port);
}
开发者ID:zhangjunfang,项目名称:jstorm-0.9.6.3-,代码行数:23,代码来源:MQContext.java
示例3: isOutTaskConnected
import backtype.storm.messaging.IConnection; //导入依赖的package包/类
private boolean isOutTaskConnected(int taskId) {
boolean ret = false;
if (workerData.getInnerTaskTransfer().get(taskId) != null) {
// Connections to inner tasks should be done after initialization.
// So return true here for all inner tasks.
ret = true;
} else {
WorkerSlot slot = taskNodeport.get(taskId);
if (slot != null) {
IConnection connection = nodeportSocket.get(slot);
if (connection != null) {
ret = connection.available();
}
}
}
return ret;
}
开发者ID:kkllwww007,项目名称:jstrom,代码行数:20,代码来源:RefreshConnections.java
示例4: onEvent
import backtype.storm.messaging.IConnection; //导入依赖的package包/类
@Override
public void onEvent(Object event, long sequence, boolean endOfBatch) throws Exception {
if (event == null) {
return;
}
long start = System.nanoTime();
try {
ITupleExt tuple = (ITupleExt) event;
int taskid = tuple.getTargetTaskId();
IConnection conn = getConnection(taskid);
if (conn != null) {
byte[] tupleMessage = serialize(tuple);
TaskMessage taskMessage = new TaskMessage(taskid, tupleMessage);
conn.send(taskMessage);
}
} finally {
long end = System.nanoTime();
serializeTimer.update((end - start)/TimeUtils.NS_PER_US);
}
}
开发者ID:kkllwww007,项目名称:jstrom,代码行数:26,代码来源:TaskTransfer.java
示例5: pullTuples
import backtype.storm.messaging.IConnection; //导入依赖的package包/类
protected void pullTuples(Object event) {
TupleExt tuple = (TupleExt) event;
int taskid = tuple.getTargetTaskId();
IConnection conn = getConnection(taskid);
if (conn != null) {
while (conn.available() == false) {
try {
Thread.sleep(1);
} catch (InterruptedException e) {
}
}
byte[] tupleMessage = serializer.serialize(tuple);
TaskMessage taskMessage = new TaskMessage(taskid, tupleMessage);
conn.send(taskMessage);
}
}
开发者ID:kkllwww007,项目名称:jstrom,代码行数:18,代码来源:TaskTransfer.java
示例6: handleEvent
import backtype.storm.messaging.IConnection; //导入依赖的package包/类
@Override
public void handleEvent(Object event, boolean endOfBatch) throws Exception {
if (event == null) {
return;
}
ITupleExt tuple = (ITupleExt) event;
int targetTask = tuple.getTargetTaskId();
IConnection conn = getConnection(targetTask);
if (conn != null) {
byte[] tupleMessage = null;
try {
//there might be errors when calling update_topology
tupleMessage = serialize(tuple);
} catch (Throwable e) {
if (Utils.exceptionCauseIsInstanceOf(KryoException.class, e)) {
throw new RuntimeException(e);
} else {
LOG.warn("serialize happened errors!!!", e);
}
}
TaskMessage message = new TaskMessage(TaskMessage.CONTROL_MESSAGE, targetTask, tupleMessage);
conn.sendDirect(message);
}
}
开发者ID:alibaba,项目名称:jstorm,代码行数:26,代码来源:DrainerCtrlRunable.java
示例7: isOutTaskConnected
import backtype.storm.messaging.IConnection; //导入依赖的package包/类
private boolean isOutTaskConnected(int taskId) {
boolean ret = false;
if (workerData.getInnerTaskTransfer().get(taskId) != null) {
// Connections to inner tasks should be done after initialization.
// So return true here for all inner tasks.
ret = true;
} else {
WorkerSlot slot = taskToNodePort.get(taskId);
if (slot != null) {
IConnection connection = nodePortToSocket.get(slot);
if (connection != null) {
ret = connection.available(taskId);
}
}
}
return ret;
}
开发者ID:alibaba,项目名称:jstorm,代码行数:20,代码来源:RefreshConnections.java
示例8: isOutboundTaskAvailable
import backtype.storm.messaging.IConnection; //导入依赖的package包/类
private boolean isOutboundTaskAvailable(int taskId) {
boolean ret = false;
DisruptorQueue targetQueue = workerData.getInnerTaskTransfer().get(taskId);
if (targetQueue != null) {
float queueLoadRatio = targetQueue.pctFull();
if (queueLoadRatio < loadMark) {
ret = true;
}
} else {
WorkerSlot slot = taskNodePort.get(taskId);
if (slot != null) {
IConnection connection = nodePortToSocket.get(slot);
if (connection != null) {
ret = connection.available(taskId);
}
}
}
if (!ret) {
LOG.debug("taskId:{} is unavailable", taskId);
}
return ret;
}
开发者ID:alibaba,项目名称:jstorm,代码行数:26,代码来源:MkShuffer.java
示例9: serialize
import backtype.storm.messaging.IConnection; //导入依赖的package包/类
protected void serialize(KryoTupleSerializer serializer, Object event) {
long start = serializeTimer.getTime();
try {
ITupleExt tuple = (ITupleExt) event;
int targetTaskId = tuple.getTargetTaskId();
IConnection conn = getConnection(targetTaskId);
if (conn != null) {
byte[] tupleMessage = serializer.serialize((TupleExt) tuple);
//LOG.info("Task-{} sent msg to task-{}, data={}", task.getTaskId(), taskid,
// JStormUtils.toPrintableString(tupleMessage));
TaskMessage taskMessage = new TaskMessage(taskId, targetTaskId, tupleMessage);
conn.send(taskMessage);
} else {
LOG.error("Can not find connection for task-{}", targetTaskId);
}
} finally {
if (MetricUtils.metricAccurateCal) {
serializeTimer.updateTime(start);
}
}
}
开发者ID:alibaba,项目名称:jstorm,代码行数:22,代码来源:TaskTransfer.java
示例10: initNettyServer
import backtype.storm.messaging.IConnection; //导入依赖的package包/类
private IConnection initNettyServer(int port) {
ConcurrentHashMap<Integer, DisruptorQueue> deserializeQueues = new ConcurrentHashMap<Integer, DisruptorQueue>();
//ConcurrentHashMap<Integer, DisruptorQueue> deserializeCtrlQueues = new ConcurrentHashMap<Integer, DisruptorQueue>();
WaitStrategy wait = (WaitStrategy)Utils.newInstance("com.lmax.disruptor.TimeoutBlockingWaitStrategy", 5, TimeUnit.MILLISECONDS);
DisruptorQueue recvControlQueue = DisruptorQueue.mkInstance("Dispatch-control", ProducerType.MULTI,
256, wait, false, 0, 0);
Set<Integer> taskSet = new HashSet<Integer>();
taskSet.add(1);
IConnection server = context.bind(null, port, deserializeQueues, recvControlQueue, true, taskSet);
WaitStrategy waitStrategy = new BlockingWaitStrategy();
DisruptorQueue recvQueue = DisruptorQueue.mkInstance("NettyUnitTest", ProducerType.SINGLE, 1024, waitStrategy, false, 0, 0);
server.registerQueue(task, recvQueue);
return server;
}
开发者ID:alibaba,项目名称:jstorm,代码行数:18,代码来源:NettyUnitTest.java
示例11: bind
import backtype.storm.messaging.IConnection; //导入依赖的package包/类
@Override
public IConnection bind(String topology_id, int port) {
IConnection retConnection = null;
try {
retConnection = new NettyServer(storm_conf, port, isSyncMode);
} catch (Throwable e) {
LOG.error("Failed to instance NettyServer", e.getCause());
JStormUtils.halt_process(-1, "Failed to bind " + port);
}
return retConnection;
}
开发者ID:zhangjunfang,项目名称:jstorm-0.9.6.3-,代码行数:14,代码来源:NettyContext.java
示例12: connect
import backtype.storm.messaging.IConnection; //导入依赖的package包/类
@Override
public IConnection connect(String topology_id, String host, int port) {
if (isSyncMode == true) {
return new NettyClientSync(storm_conf, clientChannelFactory, clientScheduleService, host, port, reconnector);
}else {
return new NettyClientAsync(storm_conf, clientChannelFactory, clientScheduleService, host, port, reconnector);
}
}
开发者ID:zhangjunfang,项目名称:jstorm-0.9.6.3-,代码行数:9,代码来源:NettyContext.java
示例13: VirtualPortDispatch
import backtype.storm.messaging.IConnection; //导入依赖的package包/类
public VirtualPortDispatch(WorkerData workerData,
IConnection recvConnection, DisruptorQueue recvQueue) {
super(recvQueue, timer, VirtualPortDispatch.class.getSimpleName(),
workerData.getActive());
this.recvConnection = recvConnection;
this.deserializeQueues = workerData.getDeserializeQueues();
Metrics.registerQueue(null, MetricDef.DISPATCH_QUEUE, queue, null, Metrics.MetricType.WORKER);
}
开发者ID:zhangjunfang,项目名称:jstorm-0.9.6.3-,代码行数:11,代码来源:VirtualPortDispatch.java
示例14: startDispatchThread
import backtype.storm.messaging.IConnection; //导入依赖的package包/类
private AsyncLoopThread startDispatchThread() {
Map stormConf = workerData.getStormConf();
int queue_size = Utils.getInt(
stormConf.get(Config.TOPOLOGY_TRANSFER_BUFFER_SIZE), 1024);
WaitStrategy waitStrategy = (WaitStrategy) Utils
.newInstance((String) stormConf
.get(Config.TOPOLOGY_DISRUPTOR_WAIT_STRATEGY));
DisruptorQueue recvQueue = DisruptorQueue.mkInstance("Dispatch", ProducerType.MULTI,
queue_size, waitStrategy);
// stop consumerStarted
//recvQueue.consumerStarted();
IContext context = workerData.getContext();
String topologyId = workerData.getTopologyId();
IConnection recvConnection = context.bind(topologyId,
workerData.getPort());
recvConnection.registerQueue(recvQueue);
RunnableCallback recvDispather = new VirtualPortDispatch(workerData,
recvConnection, recvQueue);
AsyncLoopThread vthread = new AsyncLoopThread(recvDispather, false,
Thread.MAX_PRIORITY, false);
return vthread;
}
开发者ID:zhangjunfang,项目名称:jstorm-0.9.6.3-,代码行数:29,代码来源:Worker.java
示例15: BatchTupleRunable
import backtype.storm.messaging.IConnection; //导入依赖的package包/类
public BatchTupleRunable(WorkerData workerData) {
super(workerData.getTransferQueue(), timer, BatchTupleRunable.class.getSimpleName(), workerData.getActive());
this.sendingQueue = workerData.getSendingQueue();
this.nodeportSocket = workerData.getNodeportSocket();
this.taskNodeport = workerData.getTaskNodeport();
this.dispatchMap = new HashMap<IConnection, List<TaskMessage>>();
this.queue = workerData.getTransferQueue();
Metrics.registerQueue(null, MetricDef.BATCH_TUPLE_QUEUE, this.queue, null, Metrics.MetricType.WORKER);
this.queue.consumerStarted();
}
开发者ID:zhangjunfang,项目名称:jstorm-0.9.6.3-,代码行数:13,代码来源:BatchTupleRunable.java
示例16: handleFinish
import backtype.storm.messaging.IConnection; //导入依赖的package包/类
public void handleFinish() {
for (Entry<IConnection, List<TaskMessage>> entry: dispatchMap.entrySet()) {
Pair<IConnection, List<TaskMessage>> pair =
new Pair<IConnection, List<TaskMessage>>(
entry.getKey(), entry.getValue());
sendingQueue.publish(pair);
}
dispatchMap.clear();
}
开发者ID:zhangjunfang,项目名称:jstorm-0.9.6.3-,代码行数:12,代码来源:BatchTupleRunable.java
示例17: test_small_message
import backtype.storm.messaging.IConnection; //导入依赖的package包/类
@Test
public void test_small_message() {
System.out.println("!!!!!!!!Start test_small_message !!!!!!!!!!!");
String req_msg = "Aloha is the most Hawaiian word.";
IConnection server = null;
IConnection client = null;
server = context.bind(null, port);
WaitStrategy waitStrategy = (WaitStrategy) Utils
.newInstance((String) storm_conf
.get(Config.TOPOLOGY_DISRUPTOR_WAIT_STRATEGY));
DisruptorQueue recvQueue = DisruptorQueue.mkInstance(
"NettyUnitTest", ProducerType.SINGLE, 1024, waitStrategy);
server.registerQueue(recvQueue);
client = context.connect(null, "localhost", port);
List<TaskMessage> list = new ArrayList<TaskMessage>();
TaskMessage message = new TaskMessage(task, req_msg.getBytes());
list.add(message);
client.send(message);
TaskMessage recv = server.recv(0);
Assert.assertEquals(req_msg, new String(recv.message()));
System.out.println("!!!!!!!!!!!!!!!!!!Test one time!!!!!!!!!!!!!!!!!");
server.close();
client.close();
System.out.println("!!!!!!!!!!!!End test_small_message!!!!!!!!!!!!!");
}
开发者ID:zhangjunfang,项目名称:jstorm-0.9.6.3-,代码行数:37,代码来源:NettyUnitTest.java
示例18: test_large_msg
import backtype.storm.messaging.IConnection; //导入依赖的package包/类
@Test
public void test_large_msg() {
System.out.println("!!!!!!!!!!start larget message test!!!!!!!!");
String req_msg = setupLargMsg();
System.out.println("!!!!Finish batch data, size:" + req_msg.length()
+ "!!!!");
IConnection server = null;
IConnection client = null;
server = context.bind(null, port);
WaitStrategy waitStrategy = (WaitStrategy) Utils
.newInstance((String) storm_conf
.get(Config.TOPOLOGY_DISRUPTOR_WAIT_STRATEGY));
DisruptorQueue recvQueue = DisruptorQueue.mkInstance(
"NettyUnitTest", ProducerType.SINGLE, 1024, waitStrategy);
server.registerQueue(recvQueue);
client = context.connect(null, "localhost", port);
List<TaskMessage> list = new ArrayList<TaskMessage>();
TaskMessage message = new TaskMessage(task, req_msg.getBytes());
list.add(message);
LOG.info("Client send data");
client.send(message);
TaskMessage recv = server.recv(0);
Assert.assertEquals(req_msg, new String(recv.message()));
client.close();
server.close();
System.out.println("!!!!!!!!!!End larget message test!!!!!!!!");
}
开发者ID:zhangjunfang,项目名称:jstorm-0.9.6.3-,代码行数:36,代码来源:NettyUnitTest.java
示例19: test_server_delay
import backtype.storm.messaging.IConnection; //导入依赖的package包/类
@Test
public void test_server_delay() throws InterruptedException {
System.out.println("!!!!!!!!!!Start delay message test!!!!!!!!");
String req_msg = setupLargMsg();
IConnection server = null;
IConnection client = null;
server = context.bind(null, port);
WaitStrategy waitStrategy = (WaitStrategy) Utils
.newInstance((String) storm_conf
.get(Config.TOPOLOGY_DISRUPTOR_WAIT_STRATEGY));
DisruptorQueue recvQueue = DisruptorQueue.mkInstance(
"NettyUnitTest", ProducerType.SINGLE, 1024, waitStrategy);
server.registerQueue(recvQueue);
client = context.connect(null, "localhost", port);
List<TaskMessage> list = new ArrayList<TaskMessage>();
TaskMessage message = new TaskMessage(task, req_msg.getBytes());
list.add(message);
LOG.info("Client send data");
client.send(message);
Thread.sleep(1000);
TaskMessage recv = server.recv(0);
Assert.assertEquals(req_msg, new String(recv.message()));
server.close();
client.close();
System.out.println("!!!!!!!!!!End delay message test!!!!!!!!");
}
开发者ID:zhangjunfang,项目名称:jstorm-0.9.6.3-,代码行数:36,代码来源:NettyUnitTest.java
示例20: bind
import backtype.storm.messaging.IConnection; //导入依赖的package包/类
@Override
public IConnection bind(String topology_id, int port, ConcurrentHashMap<Integer, DisruptorQueue> deserializedueue) {
IConnection retConnection = null;
try {
retConnection = new NettyServer(storm_conf, port, isSyncMode, deserializedueue);
} catch (Throwable e) {
LOG.error("Failed to instance NettyServer", e.getCause());
JStormUtils.halt_process(-1, "Failed to bind " + port);
}
return retConnection;
}
开发者ID:kkllwww007,项目名称:jstrom,代码行数:14,代码来源:NettyContext.java
注:本文中的backtype.storm.messaging.IConnection类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论