private void push(Message message) { ReadWriteBuffer<Message> buffer = this.buffer; if (buffer != null) { LOGGER.trace("[{}] push({})", consumerId, message); if (buffer.put(message) != null) { // notify the loss of messages if the ring buffer is full if (full == null) { full = new ContextualNotification( topologyService .getEntityContext(topologyService.getCurrentServerName(), consumerId) .get(), "LOST_MESSAGES"); } buffer.put(new DefaultMessage(nextSequence(), "NOTIFICATION", full)); } } }
@Override public String sendManagementCallRequest( ClientDescriptor caller, final Context context, String capabilityName, String methodName, Class<?> returnType, Parameter... parameters) { LOGGER.trace( "[{}] sendManagementCallRequest({}, {}, {})", consumerId, context, capabilityName, methodName); String managementCallIdentifier = UUID.randomUUID().toString(); Context fullContext = null; if (context.contains(Client.KEY)) { // handle client call ClientIdentifier to = ClientIdentifier.valueOf(context.get(Client.KEY)); fullContext = context.with( topologyService .getManageableClientContext(to) .orElseThrow( () -> new IllegalStateException( "Client " + to + " is either not found or not manageable"))); } if ((context.contains(Server.NAME_KEY) || context.contains(Server.KEY)) && (context.contains(ServerEntity.CONSUMER_ID) || context.contains(ServerEntity.TYPE_KEY) && context.contains(ServerEntity.NAME_KEY))) { // handle entity call String serverName = context.getOrDefault(Server.NAME_KEY, context.get(Server.KEY)); Context entityCtx = (context.contains(ServerEntity.CONSUMER_ID) ? topologyService.getManageableEntityContext( serverName, Long.parseLong(context.get(ServerEntity.CONSUMER_ID))) : topologyService.getManageableEntityContext( serverName, context.get(ServerEntity.NAME_KEY), context.get(ServerEntity.TYPE_KEY))) .orElseThrow( () -> new IllegalStateException( "Server Entity " + context + " is either not found or not manageable")); fullContext = context.with(entityCtx); } if (fullContext == null) { throw new IllegalArgumentException(context.toString()); } track(caller, managementCallIdentifier); eventService.fireManagementCallRequest( managementCallIdentifier, new ContextualCall<>(fullContext, capabilityName, methodName, returnType, parameters)); return managementCallIdentifier; }
@Override public Cluster readTopology() { LOGGER.trace("[{}] readTopology()", consumerId); return topologyService.getClusterCopy(); }