void waitForActive(final boolean isActive) throws Exception { for (int k = 0; k < WAIT_COUNT; k++) { Thread.sleep(WAIT_SLEEP); if (isActive) { for (final Channel channel : group) { final ServerHandler handler = channel.pipeline().get( ServerHandler.class); if (handler != null && handler.isActive) { return; } } } else { if (group.isEmpty()) { return; } } } }
public void inspectMetric(final String id, Metric metric) { if (connected.isEmpty()) { return; } try { sendInspectPacket(new WriteMetricEvent(id, metric)); } catch (Exception e) { log.error("Failed to inspect metric {}", metric, e); } }
@Override public void inspectBatch(final String id, final Batch batch) { if (connected.isEmpty()) { return; } try { sendInspectPacket(new WriteBatchEvent(id, batch)); } catch (Exception e) { log.error("Failed to inspect batch {}", batch, e); } }
public void inspectEvent(final String id, Event event) { if (connected.isEmpty()) { return; } try { sendInspectPacket(new WriteEventEvent(id, event)); } catch (Exception e) { log.error("Failed to inspect event {}", event, e); } }
private void pushMessageToConsumer(RemotingTransporter sendConsumerRemotingTrasnporter, String serviceName) throws RemotingSendRequestException, RemotingTimeoutException, InterruptedException { // 所有的订阅者的channel集合 if (!subscriberChannels.isEmpty()) { for (Channel channel : subscriberChannels) { if (isChannelSubscribeOnServiceMeta(serviceName, channel)) { RemotingTransporter remotingTransporter = this.defaultRegistryServer.getRemotingServer().invokeSync(channel, sendConsumerRemotingTrasnporter, 3000l); // 如果是ack返回是null说明是超时了,需要重新发送 if (remotingTransporter == null) { logger.warn("push consumer message time out,need send again"); MessageNonAck msgNonAck = new MessageNonAck(remotingTransporter, channel,serviceName); messagesNonAcks.add(msgNonAck); } // 如果消费者端消费者消费失败 AckCustomBody ackCustomBody = (AckCustomBody) remotingTransporter.getCustomHeader(); if (!ackCustomBody.isSuccess()) { logger.warn("consumer fail handler this message"); MessageNonAck msgNonAck = new MessageNonAck(remotingTransporter, channel,serviceName); messagesNonAcks.add(msgNonAck); } } } } }