@Deprecated public boolean block(long durationNanos) { return delay(durationNanos); }
@Deprecated public boolean blockUntil(long msTime) { return delayUntil(msTime); }
/** * * @param msTime time to delay in miliseconds * @return true if msgCommandChannel.goHasRoom <p> else return false */ public boolean delayUntil(long msTime) { assert(msgCommandChannel.enterBlockOk()) : "Concurrent usage error, ensure this never called concurrently"; try { if (msgCommandChannel.goHasRoom()) { MsgCommandChannel.publishBlockChannelUntil(msTime, msgCommandChannel); return true; } else { return false; } } finally { assert(msgCommandChannel.exitBlockOk()) : "Concurrent usage error, ensure this never called concurrently"; } }
/** * * @param durationNanos delay in nanoseconds * @return true if msgCommandChannel.goHasRoom <p> else return false */ public boolean delay(long durationNanos) { assert(msgCommandChannel.enterBlockOk()) : "Concurrent usage error, ensure this never called concurrently"; try { if (msgCommandChannel.goHasRoom()) { MsgCommandChannel.publishBlockChannel(durationNanos, msgCommandChannel); return true; } else { return false; } } finally { assert(msgCommandChannel.exitBlockOk()) : "Concurrent usage error, ensure this never called concurrently"; } }
/** * start shutdown of the runtime, this can be vetoed or postponed by any shutdown listeners */ public void requestShutdown() { assert(msgCommandChannel.enterBlockOk()) : "Concurrent usage error, ensure this never called concurrently"; try { msgCommandChannel.builder.requestShutdown(); } finally { assert(msgCommandChannel.exitBlockOk()) : "Concurrent usage error, ensure this never called concurrently"; } } }
return msgCommandChannel.publishOnPrivateTopic(token); } else { if (msgCommandChannel.goHasRoom() && PipeWriter.tryWriteFragment(msgCommandChannel.messagePubSub, MessagePubSub.MSG_PUBLISH_103)) { output.openField(); output.write(topic); MsgCommandChannel.publicTrackedTopicSuffix(msgCommandChannel, output); PipeWriter.publishWrites(msgCommandChannel.messagePubSub); MsgCommandChannel.publishGo(1,msgCommandChannel.builder.pubSubIndex(), msgCommandChannel);
return msgCommandChannel.publishFailableOnPrivateTopic(token, writable); } else { if (msgCommandChannel.goHasRoom() && PipeWriter.hasRoomForWrite(msgCommandChannel.messagePubSub)) { PubSubWriter pw = (PubSubWriter) Pipe.outputStream(msgCommandChannel.messagePubSub); output.append(topic); MsgCommandChannel.publicTrackedTopicSuffix(msgCommandChannel, output); MsgCommandChannel.publishGo(1, msgCommandChannel.builder.pubSubIndex(), msgCommandChannel);
if (msgCommandChannel.goHasRoom() && PipeWriter.tryWriteFragment(msgCommandChannel.messagePubSub, MessagePubSub.MSG_UNSUBSCRIBE_101)) { output.append(topic); MsgCommandChannel.publicTrackedTopicSuffix(msgCommandChannel, output);
/** * * @param session ClientHostPortInstance used as an arg for PipeWriter * @return true or false */ public boolean httpClose(ClientHostPortInstance session) { assert(msgCommandChannel.builder.getHTTPClientConfig() != null); assert((msgCommandChannel.initFeatures & MsgCommandChannel.NET_REQUESTER)!=0) : "must turn on NET_REQUESTER to use this method"; if (msgCommandChannel.goHasRoom() && Pipe.hasRoomForWrite(msgCommandChannel.httpRequest) ) { int size = Pipe.addMsgIdx(msgCommandChannel.httpRequest, ClientHTTPRequestSchema.MSG_CLOSECONNECTION_104); Pipe.addIntValue(session.sessionId, msgCommandChannel.httpRequest); Pipe.addIntValue(session.port, msgCommandChannel.httpRequest); Pipe.addIntValue(session.hostId, msgCommandChannel.httpRequest); Pipe.addLongValue(session.getConnectionId(), msgCommandChannel.httpRequest); Pipe.confirmLowLevelWrite(msgCommandChannel.httpRequest, size); Pipe.publishWrites(msgCommandChannel.httpRequest); MsgCommandChannel.publishGo(1, msgCommandChannel.builder.netIndex(), msgCommandChannel); return true; } return false; }
/** * * @param msgCommandChannel MsgCommandChannel arg used in * @param queueLength int arg specifying que length * @param maxMessageSize int arg specifying max message size */ public HTTPResponseService(MsgCommandChannel<?> msgCommandChannel, int queueLength, int maxMessageSize) { this.msgCommandChannel = msgCommandChannel; MsgCommandChannel.growCommandCountRoom(msgCommandChannel, queueLength); msgCommandChannel.initFeatures |= MsgCommandChannel.NET_RESPONDER; msgCommandChannel.pcm.ensureSize(ServerResponseSchema.class, queueLength, Math.max(minHeader, maxMessageSize)); assert(setupValidator()); }
/** * * @return null if goPipe == null else PipeWriter.hasRoomForWrite(goPipe) */ public boolean goHasRoom() { return goHasRoomFor(1); }
/** * * @param id int id to be passed to builder.serialStoreWrite * @return new SerialStoreProducer(myPipe) */ public SerialStoreProducer newSerialStoreProducer(int id) { if (isInit) { throw new UnsupportedOperationException("Too late, ensureHTTPClientRequesting method must be called in define behavior."); } this.initFeatures |= USE_SERIAL_STORE; Pipe<PersistedBlobStoreProducerSchema> myPipe = builder.serialStoreWrite[id]; if (null==myPipe) { throw new UnsupportedOperationException("only 1 command channel can write into this store "+id); } builder.serialStoreWrite[id]=null; serialStoreProdPipes = growP(serialStoreProdPipes, myPipe); return new SerialStoreProducer(myPipe); }
/** * * @param id int id be passed to builder.serialStoreRequestReplay * @return SerialStoreProducer(myPipe) */ public SerialStoreConsumer newSerialStoreConsumer(int id) { if (isInit) { throw new UnsupportedOperationException("Too late, ensureHTTPClientRequesting method must be called in define behavior."); } this.initFeatures |= USE_SERIAL_STORE; Pipe<PersistedBlobStoreConsumerSchema> myPipe = builder.serialStoreRequestReplay[id]; if (null==myPipe) { throw new UnsupportedOperationException("only 1 command channel can request replay for this store "+id); } builder.serialStoreRequestReplay[id] = null; serialStoreConsPipes = growC(serialStoreConsPipes,myPipe); return new SerialStoreConsumer(myPipe); }
/** * Takes previous state and changes it to specified state * @param state used to convert original * @param <E> enum for states * @return boolean did xmit change */ public <E extends Enum<E>> boolean changeStateTo(E state) { assert((0 != (msgCommandChannel.initFeatures & MsgCommandChannel.DYNAMIC_MESSAGING))) : "CommandChannel must be created with DYNAMIC_MESSAGING flag"; assert(msgCommandChannel.builder.isValidState(state)); if (!msgCommandChannel.builder.isValidState(state)) { throw new UnsupportedOperationException("no match "+state.getClass()); } if (msgCommandChannel.goHasRoom() && PipeWriter.tryWriteFragment(msgCommandChannel.messagePubSub, MessagePubSub.MSG_CHANGESTATE_70)) { PipeWriter.writeInt(msgCommandChannel.messagePubSub, MessagePubSub.MSG_CHANGESTATE_70_FIELD_ORDINAL_7, state.ordinal()); PipeWriter.publishWrites(msgCommandChannel.messagePubSub); msgCommandChannel.builder.releasePubSubTraffic(1, msgCommandChannel); return true; } return false; }
assert(writable != null); int token = msgCommandChannel.tokenForPrivateTopic(topic); return msgCommandChannel.publishOnPrivateTopic(token, writable); } else { if (msgCommandChannel.goHasRoom() && PipeWriter.tryWriteFragment(msgCommandChannel.messagePubSub, MessagePubSub.MSG_PUBLISH_103)) { DataOutputBlobWriter.openField(pw); topic.write(pw); MsgCommandChannel.publicTrackedTopicSuffix(msgCommandChannel, pw); DataOutputBlobWriter.closeHighLevelField(pw, MessagePubSub.MSG_PUBLISH_103_FIELD_TOPIC_1); MsgCommandChannel.publishGo(1,msgCommandChannel.builder.pubSubIndex(), msgCommandChannel);
return msgCommandChannel.publishFailableOnPrivateTopic(token, writable); } else { if (msgCommandChannel.goHasRoom() && PipeWriter.hasRoomForWrite(msgCommandChannel.messagePubSub)) { PubSubWriter pw = (PubSubWriter) Pipe.outputStream(msgCommandChannel.messagePubSub); output.write(topicBytes, 0, topicBytes.length); MsgCommandChannel.publicTrackedTopicSuffix(msgCommandChannel, output); MsgCommandChannel.publishGo(1, msgCommandChannel.builder.pubSubIndex(), msgCommandChannel);
/** * Causes this channel to delay processing any actions until the specified * amount of time has elapsed. * * @param durationNanos Nanos to delay * * @return True if blocking was successful, and false otherwise. */ @Deprecated public boolean delay(long durationNanos) { assert(enterBlockOk()) : "Concurrent usage error, ensure this never called concurrently"; try { if (goHasRoom()) { MsgCommandChannel.publishBlockChannel(durationNanos, this); return true; } else { return false; } } finally { assert(exitBlockOk()) : "Concurrent usage error, ensure this never called concurrently"; } }
/** * start shutdown of the runtime, this can be vetoed or postponed by any shutdown listeners */ public void requestShutdown() { assert(msgCommandChannel.enterBlockOk()) : "Concurrent usage error, ensure this never called concurrently"; try { msgCommandChannel.builder.requestShutdown(); } finally { assert(msgCommandChannel.exitBlockOk()) : "Concurrent usage error, ensure this never called concurrently"; } }
if (msgCommandChannel.goHasRoom() && PipeWriter.tryWriteFragment(msgCommandChannel.messagePubSub, MessagePubSub.MSG_SUBSCRIBE_100)) { output.append(topic); MsgCommandChannel.publicTrackedTopicSuffix(msgCommandChannel, output);