use of zmq.pipe.Pipe in project jeromq by zeromq.
the class SocketBase method processTerm.
@Override
protected final void processTerm(int linger) {
// Unregister all inproc endpoints associated with this socket.
// Doing this we make sure that no new pipes from other sockets (inproc)
// will be initiated.
unregisterEndpoints(this);
// Ask all attached pipes to terminate.
for (Pipe pipe : pipes) {
pipe.sendDisconnectMsg();
pipe.terminate(false);
}
registerTermAcks(pipes.size());
// Continue the termination process immediately.
super.processTerm(linger);
}
use of zmq.pipe.Pipe in project jeromq by zeromq.
the class SessionBase method zapConnect.
public int zapConnect() {
assert (zapPipe == null);
Ctx.Endpoint peer = findEndpoint("inproc://zeromq.zap.01");
if (peer.socket == null) {
errno.set(ZError.ECONNREFUSED);
return ZError.ECONNREFUSED;
}
if (peer.options.type != ZMQ.ZMQ_REP && peer.options.type != ZMQ.ZMQ_ROUTER && peer.options.type != ZMQ.ZMQ_SERVER) {
errno.set(ZError.ECONNREFUSED);
return ZError.ECONNREFUSED;
}
// Create a bi-directional pipe that will connect
// session with zap socket.
ZObject[] parents = { this, peer.socket };
int[] hwms = { 0, 0 };
boolean[] conflates = { false, false };
Pipe[] pipes = Pipe.pair(parents, hwms, conflates);
// Attach local end of the pipe to this socket object.
zapPipe = pipes[0];
zapPipe.setNoDelay();
zapPipe.setEventSink(this);
sendBind(peer.socket, pipes[1], false);
// Send empty identity if required by the peer.
if (peer.options.recvIdentity) {
Msg id = new Msg();
id.setFlags(Msg.IDENTITY);
zapPipe.write(id);
zapPipe.flush();
}
return 0;
}
use of zmq.pipe.Pipe in project jeromq by zeromq.
the class MTrieTest method testAddRemoveMultiNodesSameLevel.
@Test
public void testAddRemoveMultiNodesSameLevel() {
Mtrie mtrie = new Mtrie();
Pipe other = createPipe();
boolean rc = mtrie.add(prefix, pipe);
assertThat(rc, is(true));
rc = mtrie.add(prefix, other);
assertThat(rc, is(false));
rc = mtrie.rm(prefix, pipe);
assertThat(rc, is(false));
rc = mtrie.rm(prefix, other);
assertThat(rc, is(true));
}
use of zmq.pipe.Pipe in project jeromq by zeromq.
the class MTrieTest method testAddRemoveMultiNodesAboveLevel.
@Test
public void testAddRemoveMultiNodesAboveLevel() {
Mtrie mtrie = new Mtrie();
Pipe other = createPipe();
Pipe third = createPipe();
boolean rc = mtrie.add(prefix, pipe);
assertThat(rc, is(true));
byte[] abv = Arrays.copyOf(prefix.data(), prefix.size());
abv[1] = 0;
Msg above = new Msg(abv);
rc = mtrie.add(above, other);
assertThat(rc, is(true));
abv[1] = 33;
above = new Msg(abv);
rc = mtrie.add(above, third);
assertThat(rc, is(true));
rc = mtrie.rm(prefix, pipe);
assertThat(rc, is(true));
abv[1] = 0;
above = new Msg(abv);
rc = mtrie.rm(above, other);
assertThat(rc, is(true));
abv[1] = 33;
above = new Msg(abv);
rc = mtrie.rm(above, third);
assertThat(rc, is(true));
}
use of zmq.pipe.Pipe in project jeromq by zeromq.
the class MTrieTest method testAddRemoveMultiNodesSameLevelWithFunctionCall.
@Test
public void testAddRemoveMultiNodesSameLevelWithFunctionCall() {
Mtrie mtrie = new Mtrie();
Pipe other = createPipe();
boolean rc = mtrie.add(prefix, pipe);
assertThat(rc, is(true));
rc = mtrie.add(prefix, other);
assertThat(rc, is(false));
rc = mtrie.rm(pipe, handler, null);
assertThat(rc, is(true));
assertThat(handler.counter.get(), is(0));
rc = mtrie.rm(other, handler, null);
assertThat(rc, is(true));
assertThat(handler.counter.get(), is(1));
}
Aggregations