com.alibaba.rocketmq.remoting.exception.RemotingTimeoutException Java Examples

The following examples show how to use com.alibaba.rocketmq.remoting.exception.RemotingTimeoutException. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: FilterServerOuterAPI.java    From RocketMQ-Master-analyze with Apache License 2.0 6 votes vote down vote up
public RegisterFilterServerResponseHeader registerFilterServerToBroker(//
        final String brokerAddr, // 1
        final String filterServerAddr// 2
) throws RemotingCommandException, RemotingConnectException, RemotingSendRequestException,
        RemotingTimeoutException, InterruptedException, MQBrokerException {
    RegisterFilterServerRequestHeader requestHeader = new RegisterFilterServerRequestHeader();
    requestHeader.setFilterServerAddr(filterServerAddr);
    RemotingCommand request =
            RemotingCommand.createRequestCommand(RequestCode.REGISTER_FILTER_SERVER, requestHeader);

    RemotingCommand response = this.remotingClient.invokeSync(brokerAddr, request, 3000);
    assert response != null;
    switch (response.getCode()) {
    case ResponseCode.SUCCESS: {
        RegisterFilterServerResponseHeader responseHeader = (RegisterFilterServerResponseHeader) response
            .decodeCommandCustomHeader(RegisterFilterServerResponseHeader.class);

        return responseHeader;
    }
    default:
        break;
    }

    throw new MQBrokerException(response.getCode(), response.getRemark());
}
 
Example #2
Source File: FilterServerOuterAPI.java    From reading-and-annotate-rocketmq-3.4.6 with GNU General Public License v3.0 6 votes vote down vote up
public RegisterFilterServerResponseHeader registerFilterServerToBroker(//
        final String brokerAddr,// 1
        final String filterServerAddr// 2
) throws RemotingCommandException, RemotingConnectException, RemotingSendRequestException,
        RemotingTimeoutException, InterruptedException, MQBrokerException {
    RegisterFilterServerRequestHeader requestHeader = new RegisterFilterServerRequestHeader();
    requestHeader.setFilterServerAddr(filterServerAddr);
    RemotingCommand request =
            RemotingCommand.createRequestCommand(RequestCode.REGISTER_FILTER_SERVER, requestHeader);

    RemotingCommand response = this.remotingClient.invokeSync(brokerAddr, request, 3000);
    assert response != null;
    switch (response.getCode()) {
    case ResponseCode.SUCCESS: {
        RegisterFilterServerResponseHeader responseHeader =
                (RegisterFilterServerResponseHeader) response
                    .decodeCommandCustomHeader(RegisterFilterServerResponseHeader.class);

        return responseHeader;
    }
    default:
        break;
    }

    throw new MQBrokerException(response.getCode(), response.getRemark());
}
 
Example #3
Source File: NettyConnectionTest.java    From reading-and-annotate-rocketmq-3.4.6 with GNU General Public License v3.0 6 votes vote down vote up
@Test
public void test_connect_timeout() throws InterruptedException, RemotingConnectException,
        RemotingSendRequestException, RemotingTimeoutException {
    RemotingClient client = createRemotingClient();

    for (int i = 0; i < 100; i++) {
        try {
            RemotingCommand request = RemotingCommand.createRequestCommand(0, null);
            RemotingCommand response = client.invokeSync("localhost:8888", request, 1000 * 3);
        }
        catch (Exception e) {
            e.printStackTrace();
        }
    }

    client.shutdown();
    System.out.println("-----------------------------------------------------------------");
}
 
Example #4
Source File: NettyIdleTest.java    From reading-and-annotate-rocketmq-3.4.6 with GNU General Public License v3.0 6 votes vote down vote up
public void test_idle_event() throws InterruptedException, RemotingConnectException,
        RemotingSendRequestException, RemotingTimeoutException {
    RemotingServer server = createRemotingServer();
    RemotingClient client = createRemotingClient();

    for (int i = 0; i < 10; i++) {
        RemotingCommand request = RemotingCommand.createRequestCommand(0, null);
        RemotingCommand response = client.invokeSync("localhost:8888", request, 1000 * 3);
        System.out.println(i + " invoke result = " + response);
        assertTrue(response != null);

        Thread.sleep(1000 * 10);
    }

    Thread.sleep(1000 * 60);

    client.shutdown();
    server.shutdown();
    System.out.println("-----------------------------------------------------------------");
}
 
Example #5
Source File: NettyRemotingClient.java    From rocketmq with Apache License 2.0 6 votes vote down vote up
@Override
public void invokeAsync(String addr, RemotingCommand request, long timeoutMillis, InvokeCallback invokeCallback)
        throws InterruptedException, RemotingConnectException, RemotingTooMuchRequestException, RemotingTimeoutException,
        RemotingSendRequestException {
    final Channel channel = this.getAndCreateChannel(addr);
    if (channel != null && channel.isActive()) {
        try {
            if (this.rpcHook != null) {
                this.rpcHook.doBeforeRequest(addr, request);
            }
            this.invokeAsyncImpl(channel, request, timeoutMillis, invokeCallback);
        } catch (RemotingSendRequestException e) {
            log.warn("invokeAsync: send request exception, so close the channel[{}]", addr);
            this.closeChannel(addr, channel);
            throw e;
        }
    } else {
        this.closeChannel(addr, channel);
        throw new RemotingConnectException(addr);
    }
}
 
Example #6
Source File: NettyRemotingClient.java    From rocketmq with Apache License 2.0 6 votes vote down vote up
@Override
public void invokeOneway(String addr, RemotingCommand request, long timeoutMillis) throws InterruptedException,
        RemotingConnectException, RemotingTooMuchRequestException, RemotingTimeoutException, RemotingSendRequestException {
    final Channel channel = this.getAndCreateChannel(addr);
    if (channel != null && channel.isActive()) {
        try {
            if (this.rpcHook != null) {
                this.rpcHook.doBeforeRequest(addr, request);
            }
            this.invokeOnewayImpl(channel, request, timeoutMillis);
        } catch (RemotingSendRequestException e) {
            log.warn("invokeOneway: send request exception, so close the channel[{}]", addr);
            this.closeChannel(addr, channel);
            throw e;
        }
    } else {
        this.closeChannel(addr, channel);
        throw new RemotingConnectException(addr);
    }
}
 
Example #7
Source File: NettyIdleTest.java    From rocketmq with Apache License 2.0 6 votes vote down vote up
public void test_idle_event() throws InterruptedException, RemotingConnectException,
        RemotingSendRequestException, RemotingTimeoutException {
    RemotingServer server = createRemotingServer();
    RemotingClient client = createRemotingClient();

    for (int i = 0; i < 10; i++) {
        RemotingCommand request = RemotingCommand.createRequestCommand(0, null);
        RemotingCommand response = client.invokeSync("localhost:8888", request, 1000 * 3);
        System.out.println(i + " invoke result = " + response);
        assertTrue(response != null);

        Thread.sleep(1000 * 10);
    }

    Thread.sleep(1000 * 60);

    client.shutdown();
    server.shutdown();
    System.out.println("-----------------------------------------------------------------");
}
 
Example #8
Source File: NettyConnectionTest.java    From rocketmq with Apache License 2.0 6 votes vote down vote up
@Test
public void test_connect_timeout() throws InterruptedException, RemotingConnectException,
        RemotingSendRequestException, RemotingTimeoutException {
    RemotingClient client = createRemotingClient();

    for (int i = 0; i < 100; i++) {
        try {
            RemotingCommand request = RemotingCommand.createRequestCommand(0, null);
            RemotingCommand response = client.invokeSync("localhost:8888", request, 1000 * 3);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    client.shutdown();
    System.out.println("-----------------------------------------------------------------");
}
 
Example #9
Source File: FilterServerOuterAPI.java    From rocketmq with Apache License 2.0 6 votes vote down vote up
public RegisterFilterServerResponseHeader registerFilterServerToBroker(//
                                                                       final String brokerAddr,// 1
                                                                       final String filterServerAddr// 2
) throws RemotingCommandException, RemotingConnectException, RemotingSendRequestException,
        RemotingTimeoutException, InterruptedException, MQBrokerException {
    RegisterFilterServerRequestHeader requestHeader = new RegisterFilterServerRequestHeader();
    requestHeader.setFilterServerAddr(filterServerAddr);
    RemotingCommand request =
            RemotingCommand.createRequestCommand(RequestCode.REGISTER_FILTER_SERVER, requestHeader);

    RemotingCommand response = this.remotingClient.invokeSync(brokerAddr, request, 3000);
    assert response != null;
    switch (response.getCode()) {
        case ResponseCode.SUCCESS: {
            RegisterFilterServerResponseHeader responseHeader =
                    (RegisterFilterServerResponseHeader) response
                            .decodeCommandCustomHeader(RegisterFilterServerResponseHeader.class);

            return responseHeader;
        }
        default:
            break;
    }

    throw new MQBrokerException(response.getCode(), response.getRemark());
}
 
Example #10
Source File: NettyRemotingClient.java    From RocketMQ-Master-analyze with Apache License 2.0 6 votes vote down vote up
@Override
public void invokeAsync(String addr, RemotingCommand request, long timeoutMillis,
        InvokeCallback invokeCallback) throws InterruptedException, RemotingConnectException,
                RemotingTooMuchRequestException, RemotingTimeoutException, RemotingSendRequestException {
    final Channel channel = this.getAndCreateChannel(addr);
    if (channel != null && channel.isActive()) {
        try {
            if (this.rpcHook != null) {
                this.rpcHook.doBeforeRequest(addr, request);
            }
            this.invokeAsyncImpl(channel, request, timeoutMillis, invokeCallback);
        }
        catch (RemotingSendRequestException e) {
            log.warn("invokeAsync: send request exception, so close the channel[{}]", addr);
            this.closeChannel(addr, channel);
            throw e;
        }
    }
    else {
        this.closeChannel(addr, channel);
        throw new RemotingConnectException(addr);
    }
}
 
Example #11
Source File: NettyRemotingClient.java    From RocketMQ-Master-analyze with Apache License 2.0 6 votes vote down vote up
@Override
public void invokeOneway(String addr, RemotingCommand request, long timeoutMillis)
        throws InterruptedException, RemotingConnectException, RemotingTooMuchRequestException,
        RemotingTimeoutException, RemotingSendRequestException {
    final Channel channel = this.getAndCreateChannel(addr);
    if (channel != null && channel.isActive()) {
        try {
            if (this.rpcHook != null) {
                this.rpcHook.doBeforeRequest(addr, request);
            }
            this.invokeOnewayImpl(channel, request, timeoutMillis);
        }
        catch (RemotingSendRequestException e) {
            log.warn("invokeOneway: send request exception, so close the channel[{}]", addr);
            this.closeChannel(addr, channel);
            throw e;
        }
    }
    else {
        this.closeChannel(addr, channel);
        throw new RemotingConnectException(addr);
    }
}
 
Example #12
Source File: NettyIdleTest.java    From RocketMQ-Master-analyze with Apache License 2.0 6 votes vote down vote up
public void test_idle_event() throws InterruptedException, RemotingConnectException,
        RemotingSendRequestException, RemotingTimeoutException {
    RemotingServer server = createRemotingServer();
    RemotingClient client = createRemotingClient();

    for (int i = 0; i < 10; i++) {
        RemotingCommand request = RemotingCommand.createRequestCommand(0, null);
        RemotingCommand response = client.invokeSync("localhost:8888", request, 1000 * 3);
        System.out.println(i + " invoke result = " + response);
        assertTrue(response != null);

        Thread.sleep(1000 * 10);
    }

    Thread.sleep(1000 * 60);

    client.shutdown();
    server.shutdown();
    System.out.println("-----------------------------------------------------------------");
}
 
Example #13
Source File: NettyConnectionTest.java    From RocketMQ-Master-analyze with Apache License 2.0 6 votes vote down vote up
@Test
public void test_connect_timeout() throws InterruptedException, RemotingConnectException,
        RemotingSendRequestException, RemotingTimeoutException {
    RemotingClient client = createRemotingClient();

    for (int i = 0; i < 100; i++) {
        try {
            RemotingCommand request = RemotingCommand.createRequestCommand(0, null);
            RemotingCommand response = client.invokeSync("localhost:8888", request, 1000 * 3);
        }
        catch (Exception e) {
            e.printStackTrace();
        }
    }

    client.shutdown();
    System.out.println("-----------------------------------------------------------------");
}
 
Example #14
Source File: CommandUtil.java    From RocketMQ-Master-analyze with Apache License 2.0 5 votes vote down vote up
public static Set<String> fetchMasterAddrByClusterName(final MQAdminExt adminExt,
        final String clusterName) throws InterruptedException, RemotingConnectException,
                RemotingTimeoutException, RemotingSendRequestException, MQBrokerException {
    Set<String> masterSet = new HashSet<String>();

    ClusterInfo clusterInfoSerializeWrapper = adminExt.examineBrokerClusterInfo();

    Set<String> brokerNameSet = clusterInfoSerializeWrapper.getClusterAddrTable().get(clusterName);

    if (brokerNameSet != null) {
        for (String brokerName : brokerNameSet) {
            BrokerData brokerData = clusterInfoSerializeWrapper.getBrokerAddrTable().get(brokerName);
            if (brokerData != null) {

                String addr = brokerData.getBrokerAddrs().get(MixAll.MASTER_ID);
                if (addr != null) {
                    masterSet.add(addr);
                }
            }
        }
    }
    else {
        System.out.printf(
            "[error] Make sure the specified clusterName exists or the nameserver which connected is correct.");
    }

    return masterSet;
}
 
Example #15
Source File: NettyRemotingClient.java    From reading-and-annotate-rocketmq-3.4.6 with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void invokeOneway(String addr, RemotingCommand request, long timeoutMillis)
        throws InterruptedException, RemotingConnectException, RemotingTooMuchRequestException,
        RemotingTimeoutException, RemotingSendRequestException {
    final Channel channel = this.getAndCreateChannel(addr);
    if (channel != null && channel.isActive()) {
        // test the channel writable or not
        if (!channel.isWritable()) {
            throw new RemotingTooMuchRequestException(String.format(
                "the channel[%s] is not writable now", channel.toString()));
        }

        try {
            if (this.rpcHook != null) {
                this.rpcHook.doBeforeRequest(addr, request);
            }
            this.invokeOnewayImpl(channel, request, timeoutMillis);
        }
        catch (RemotingSendRequestException e) {
            log.warn("invokeOneway: send request exception, so close the channel[{}]", addr);
            this.closeChannel(addr, channel);
            throw e;
        }
    }
    else {
        this.closeChannel(addr, channel);
        throw new RemotingConnectException(addr);
    }
}
 
Example #16
Source File: NettyRemotingClient.java    From reading-and-annotate-rocketmq-3.4.6 with GNU General Public License v3.0 5 votes vote down vote up
@Override //异步从addr地址获取报文信息.
public void invokeAsync(String addr, RemotingCommand request, long timeoutMillis,
        InvokeCallback invokeCallback) throws InterruptedException, RemotingConnectException,
        RemotingTooMuchRequestException, RemotingTimeoutException, RemotingSendRequestException {
    final Channel channel = this.getAndCreateChannel(addr);
    if (channel != null && channel.isActive()) {
        // test the channel writable or not
        if (!channel.isWritable()) {
            throw new RemotingTooMuchRequestException(String.format(
                "the channel[%s] is not writable now", channel.toString()));
        }

        try {
            if (this.rpcHook != null) {
                this.rpcHook.doBeforeRequest(addr, request);
            }
            this.invokeAsyncImpl(channel, request, timeoutMillis, invokeCallback);
        }
        catch (RemotingSendRequestException e) {
            log.warn("invokeAsync: send request exception, so close the channel[{}]", addr);
            this.closeChannel(addr, channel);
            throw e;
        }
    }
    else {
        this.closeChannel(addr, channel);
        throw new RemotingConnectException(addr);
    }
}
 
Example #17
Source File: MQAdminExtImpl.java    From rocket-console with Apache License 2.0 5 votes vote down vote up
@Override
public ClusterInfo examineBrokerClusterInfo()
        throws InterruptedException, MQBrokerException, RemotingTimeoutException, RemotingSendRequestException,
        RemotingConnectException {
    logger.info("I am test");
    return MQAdminInstance.threadLocalMQAdminExt().examineBrokerClusterInfo();
}
 
Example #18
Source File: CommandUtil.java    From reading-and-annotate-rocketmq-3.4.6 with GNU General Public License v3.0 5 votes vote down vote up
public static Set<String> fetchMasterAddrByClusterName(final MQAdminExt adminExt, final String clusterName)
        throws InterruptedException, RemotingConnectException, RemotingTimeoutException,
        RemotingSendRequestException, MQBrokerException {
    Set<String> masterSet = new HashSet<String>();

    ClusterInfo clusterInfoSerializeWrapper = adminExt.examineBrokerClusterInfo();

    Set<String> brokerNameSet = clusterInfoSerializeWrapper.getClusterAddrTable().get(clusterName);

    if (brokerNameSet != null) {
        for (String brokerName : brokerNameSet) {
            BrokerData brokerData = clusterInfoSerializeWrapper.getBrokerAddrTable().get(brokerName);
            if (brokerData != null) {

                String addr = brokerData.getBrokerAddrs().get(MixAll.MASTER_ID);
                if (addr != null) {
                    masterSet.add(addr);
                }
            }
        }
    }
    else {
        System.out
            .printf("[error] Make sure the specified clusterName exists or the nameserver which connected is correct.");
    }

    return masterSet;
}
 
Example #19
Source File: CommandUtil.java    From rocketmq with Apache License 2.0 5 votes vote down vote up
public static Set<String> fetchMasterAddrByClusterName(final MQAdminExt adminExt, final String clusterName)
        throws InterruptedException, RemotingConnectException, RemotingTimeoutException,
        RemotingSendRequestException, MQBrokerException {
    Set<String> masterSet = new HashSet<String>();

    ClusterInfo clusterInfoSerializeWrapper = adminExt.examineBrokerClusterInfo();

    Set<String> brokerNameSet = clusterInfoSerializeWrapper.getClusterAddrTable().get(clusterName);

    if (brokerNameSet != null) {
        for (String brokerName : brokerNameSet) {
            BrokerData brokerData = clusterInfoSerializeWrapper.getBrokerAddrTable().get(brokerName);
            if (brokerData != null) {

                String addr = brokerData.getBrokerAddrs().get(MixAll.MASTER_ID);
                if (addr != null) {
                    masterSet.add(addr);
                }
            }
        }
    } else {
        System.out
                .printf("[error] Make sure the specified clusterName exists or the nameserver which connected is correct.");
    }

    return masterSet;
}
 
Example #20
Source File: NettyRemotingAbstract.java    From rocketmq with Apache License 2.0 5 votes vote down vote up
public RemotingCommand invokeSyncImpl(final Channel channel, final RemotingCommand request, final long timeoutMillis)
        throws InterruptedException, RemotingSendRequestException, RemotingTimeoutException {
    final int opaque = request.getOpaque();

    try {
        final ResponseFuture responseFuture = new ResponseFuture(opaque, timeoutMillis, null, null);
        this.responseTable.put(opaque, responseFuture);
        final SocketAddress addr = channel.remoteAddress();
        channel.writeAndFlush(request).addListener(new ChannelFutureListener() {
            @Override
            public void operationComplete(ChannelFuture f) throws Exception {
                if (f.isSuccess()) {
                    responseFuture.setSendRequestOK(true);
                    return;
                } else {
                    responseFuture.setSendRequestOK(false);
                }

                responseTable.remove(opaque);
                responseFuture.setCause(f.cause());
                responseFuture.putResponse(null);
                plog.warn("send a request command to channel <" + addr + "> failed.");
            }
        });

        RemotingCommand responseCommand = responseFuture.waitResponse(timeoutMillis);
        if (null == responseCommand) {
            if (responseFuture.isSendRequestOK()) {
                throw new RemotingTimeoutException(RemotingHelper.parseSocketAddressAddr(addr), timeoutMillis,
                        responseFuture.getCause());
            } else {
                throw new RemotingSendRequestException(RemotingHelper.parseSocketAddressAddr(addr), responseFuture.getCause());
            }
        }

        return responseCommand;
    } finally {
        this.responseTable.remove(opaque);
    }
}
 
Example #21
Source File: NettyRemotingAbstract.java    From rocketmq with Apache License 2.0 5 votes vote down vote up
public void invokeOnewayImpl(final Channel channel, final RemotingCommand request, final long timeoutMillis)
        throws InterruptedException, RemotingTooMuchRequestException, RemotingTimeoutException, RemotingSendRequestException {
    request.markOnewayRPC();
    boolean acquired = this.semaphoreOneway.tryAcquire(timeoutMillis, TimeUnit.MILLISECONDS);
    if (acquired) {
        final SemaphoreReleaseOnlyOnce once = new SemaphoreReleaseOnlyOnce(this.semaphoreOneway);
        try {
            channel.writeAndFlush(request).addListener(new ChannelFutureListener() {
                @Override
                public void operationComplete(ChannelFuture f) throws Exception {
                    once.release();
                    if (!f.isSuccess()) {
                        plog.warn("send a request command to channel <" + channel.remoteAddress() + "> failed.");
                    }
                }
            });
        } catch (Exception e) {
            once.release();
            plog.warn("write send a request command to channel <" + channel.remoteAddress() + "> failed.");
            throw new RemotingSendRequestException(RemotingHelper.parseChannelRemoteAddr(channel), e);
        }
    } else {
        if (timeoutMillis <= 0) {
            throw new RemotingTooMuchRequestException("invokeOnewayImpl invoke too fast");
        } else {
            String info = String.format(
                    "invokeOnewayImpl tryAcquire semaphore timeout, %dms, waiting thread nums: %d semaphoreAsyncValue: %d", //
                    timeoutMillis, //
                    this.semaphoreAsync.getQueueLength(), //
                    this.semaphoreAsync.availablePermits()//
            );
            plog.warn(info);
            throw new RemotingTimeoutException(info);
        }
    }
}
 
Example #22
Source File: RemotingServer.java    From rocketmq with Apache License 2.0 4 votes vote down vote up
void invokeOneway(final Channel channel, final RemotingCommand request, final long timeoutMillis)
throws InterruptedException, RemotingTooMuchRequestException, RemotingTimeoutException,
RemotingSendRequestException;
 
Example #23
Source File: RemotingServer.java    From rocketmq with Apache License 2.0 4 votes vote down vote up
void invokeAsync(final Channel channel, final RemotingCommand request, final long timeoutMillis,
         final InvokeCallback invokeCallback) throws InterruptedException,
RemotingTooMuchRequestException, RemotingTimeoutException, RemotingSendRequestException;
 
Example #24
Source File: MQAdminExtImpl.java    From rocket-console with Apache License 2.0 4 votes vote down vote up
@Override
public void updateBrokerConfig(String brokerAddr, Properties properties)
        throws RemotingConnectException, RemotingSendRequestException, RemotingTimeoutException,
        UnsupportedEncodingException, InterruptedException, MQBrokerException {
    MQAdminInstance.threadLocalMQAdminExt().updateBrokerConfig(brokerAddr, properties);
}
 
Example #25
Source File: RemotingServer.java    From rocketmq with Apache License 2.0 4 votes vote down vote up
RemotingCommand invokeSync(final Channel channel, final RemotingCommand request,
                   final long timeoutMillis) throws InterruptedException, RemotingSendRequestException,
RemotingTimeoutException;
 
Example #26
Source File: Broker2Client.java    From rocketmq with Apache License 2.0 4 votes vote down vote up
public RemotingCommand callClient(//
                                  final Channel channel,//
                                  final RemotingCommand request//
) throws RemotingSendRequestException, RemotingTimeoutException, InterruptedException {
    return this.brokerController.getRemotingServer().invokeSync(channel, request, 10000);
}
 
Example #27
Source File: ClusterListSubCommand.java    From RocketMQ-Master-analyze with Apache License 2.0 4 votes vote down vote up
private void printClusterMoreStats(final DefaultMQAdminExt defaultMQAdminExt)
        throws RemotingConnectException, RemotingTimeoutException, RemotingSendRequestException,
        InterruptedException, MQBrokerException {

    ClusterInfo clusterInfoSerializeWrapper = defaultMQAdminExt.examineBrokerClusterInfo();

    System.out.printf("%-16s  %-32s %14s %14s %14s %14s\n", //
        "#Cluster Name", //
        "#Broker Name", //
        "#InTotalYest", //
        "#OutTotalYest", //
        "#InTotalToday", //
        "#OutTotalToday"//
    );

    Iterator<Map.Entry<String, Set<String>>> itCluster =
            clusterInfoSerializeWrapper.getClusterAddrTable().entrySet().iterator();
    while (itCluster.hasNext()) {
        Map.Entry<String, Set<String>> next = itCluster.next();
        String clusterName = next.getKey();
        TreeSet<String> brokerNameSet = new TreeSet<String>();
        brokerNameSet.addAll(next.getValue());

        for (String brokerName : brokerNameSet) {
            BrokerData brokerData = clusterInfoSerializeWrapper.getBrokerAddrTable().get(brokerName);
            if (brokerData != null) {

                Iterator<Map.Entry<Long, String>> itAddr =
                        brokerData.getBrokerAddrs().entrySet().iterator();
                while (itAddr.hasNext()) {
                    Map.Entry<Long, String> next1 = itAddr.next();
                    long InTotalYest = 0;
                    long OutTotalYest = 0;
                    long InTotalToday = 0;
                    long OutTotalToday = 0;

                    try {
                        KVTable kvTable = defaultMQAdminExt.fetchBrokerRuntimeStats(next1.getValue());
                        String msgPutTotalYesterdayMorning =
                                kvTable.getTable().get("msgPutTotalYesterdayMorning");
                        String msgPutTotalTodayMorning =
                                kvTable.getTable().get("msgPutTotalTodayMorning");
                        String msgPutTotalTodayNow = kvTable.getTable().get("msgPutTotalTodayNow");
                        String msgGetTotalYesterdayMorning =
                                kvTable.getTable().get("msgGetTotalYesterdayMorning");
                        String msgGetTotalTodayMorning =
                                kvTable.getTable().get("msgGetTotalTodayMorning");
                        String msgGetTotalTodayNow = kvTable.getTable().get("msgGetTotalTodayNow");

                        InTotalYest = Long.parseLong(msgPutTotalTodayMorning)
                                - Long.parseLong(msgPutTotalYesterdayMorning);
                        OutTotalYest = Long.parseLong(msgGetTotalTodayMorning)
                                - Long.parseLong(msgGetTotalYesterdayMorning);

                        InTotalToday = Long.parseLong(msgPutTotalTodayNow)
                                - Long.parseLong(msgPutTotalTodayMorning);
                        OutTotalToday = Long.parseLong(msgGetTotalTodayNow)
                                - Long.parseLong(msgGetTotalTodayMorning);

                    }
                    catch (Exception e) {
                    }

                    System.out.printf("%-16s  %-32s %14d %14d %14d %14d\n", //
                        clusterName, //
                        brokerName, //
                        InTotalYest, //
                        OutTotalYest, //
                        InTotalToday, //
                        OutTotalToday//
                    );
                }
            }
        }

        if (itCluster.hasNext()) {
            System.out.println("");
        }
    }
}
 
Example #28
Source File: RemotingClient.java    From RocketMQ-Master-analyze with Apache License 2.0 4 votes vote down vote up
public void invokeAsync(final String addr, final RemotingCommand request, final long timeoutMillis,
final InvokeCallback invokeCallback) throws InterruptedException, RemotingConnectException,
        RemotingTooMuchRequestException, RemotingTimeoutException, RemotingSendRequestException;
 
Example #29
Source File: RemotingClient.java    From RocketMQ-Master-analyze with Apache License 2.0 4 votes vote down vote up
public void invokeOneway(final String addr, final RemotingCommand request, final long timeoutMillis)
throws InterruptedException, RemotingConnectException, RemotingTooMuchRequestException,
RemotingTimeoutException, RemotingSendRequestException;
 
Example #30
Source File: NettyRemotingServer.java    From reading-and-annotate-rocketmq-3.4.6 with GNU General Public License v3.0 4 votes vote down vote up
@Override
public RemotingCommand invokeSync(final Channel channel, final RemotingCommand request, final long timeoutMillis)
        throws InterruptedException, RemotingSendRequestException, RemotingTimeoutException {
    return this.invokeSyncImpl(channel, request, timeoutMillis);
}