Search in sources :

Example 1 with ScheduledTaskStatisticsImpl

use of com.hazelcast.scheduledexecutor.impl.ScheduledTaskStatisticsImpl in project hazelcast by hazelcast.

the class ClientScheduledFutureProxy method getStats.

@Override
public ScheduledTaskStatistics getStats() {
    checkAccessibleHandler();
    Address address = handler.getAddress();
    String schedulerName = handler.getSchedulerName();
    String taskName = handler.getTaskName();
    int partitionId = handler.getPartitionId();
    try {
        if (address != null) {
            ClientMessage request = ScheduledExecutorGetStatsFromAddressCodec.encodeRequest(schedulerName, taskName, address);
            ClientMessage response = new ClientInvocation(getClient(), request, address).invoke().get();
            ScheduledExecutorGetStatsFromAddressCodec.ResponseParameters responseParameters = ScheduledExecutorGetStatsFromAddressCodec.decodeResponse(response);
            return new ScheduledTaskStatisticsImpl(responseParameters.totalRuns, responseParameters.lastIdleTimeNanos, responseParameters.totalRunTimeNanos, responseParameters.totalIdleTimeNanos);
        } else {
            ClientMessage request = ScheduledExecutorGetStatsFromPartitionCodec.encodeRequest(schedulerName, taskName);
            ClientMessage response = new ClientInvocation(getClient(), request, partitionId).invoke().get();
            ScheduledExecutorGetStatsFromAddressCodec.ResponseParameters responseParameters = ScheduledExecutorGetStatsFromAddressCodec.decodeResponse(response);
            return new ScheduledTaskStatisticsImpl(responseParameters.totalRuns, responseParameters.lastIdleTimeNanos, responseParameters.totalRunTimeNanos, responseParameters.totalIdleTimeNanos);
        }
    } catch (Exception e) {
        throw ExceptionUtil.rethrow(e);
    }
}
Also used : Address(com.hazelcast.nio.Address) ClientInvocation(com.hazelcast.client.spi.impl.ClientInvocation) ClientMessage(com.hazelcast.client.impl.protocol.ClientMessage) ScheduledExecutorGetStatsFromAddressCodec(com.hazelcast.client.impl.protocol.codec.ScheduledExecutorGetStatsFromAddressCodec) ScheduledTaskStatisticsImpl(com.hazelcast.scheduledexecutor.impl.ScheduledTaskStatisticsImpl) StaleTaskException(com.hazelcast.scheduledexecutor.StaleTaskException) TimeoutException(java.util.concurrent.TimeoutException) ExecutionException(java.util.concurrent.ExecutionException)

Example 2 with ScheduledTaskStatisticsImpl

use of com.hazelcast.scheduledexecutor.impl.ScheduledTaskStatisticsImpl in project hazelcast by hazelcast.

the class ClientScheduledFutureProxy method getStats.

@Override
public ScheduledTaskStatistics getStats() {
    checkAccessibleHandler();
    UUID uuid = handler.getUuid();
    String schedulerName = handler.getSchedulerName();
    String taskName = handler.getTaskName();
    int partitionId = handler.getPartitionId();
    if (uuid != null) {
        ClientMessage request = ScheduledExecutorGetStatsFromMemberCodec.encodeRequest(schedulerName, taskName, uuid);
        ClientMessage response = invokeOnMember(request, uuid);
        ScheduledExecutorGetStatsFromMemberCodec.ResponseParameters responseParameters = ScheduledExecutorGetStatsFromMemberCodec.decodeResponse(response);
        return new ScheduledTaskStatisticsImpl(responseParameters.totalRuns, responseParameters.lastIdleTimeNanos, responseParameters.totalRunTimeNanos, responseParameters.totalIdleTimeNanos, responseParameters.lastRunDurationNanos);
    } else {
        ClientMessage request = ScheduledExecutorGetStatsFromPartitionCodec.encodeRequest(schedulerName, taskName);
        ClientMessage response = invokeOnPartition(request, partitionId);
        ScheduledExecutorGetStatsFromMemberCodec.ResponseParameters responseParameters = ScheduledExecutorGetStatsFromMemberCodec.decodeResponse(response);
        return new ScheduledTaskStatisticsImpl(responseParameters.totalRuns, responseParameters.lastIdleTimeNanos, responseParameters.totalRunTimeNanos, responseParameters.totalIdleTimeNanos, responseParameters.lastRunDurationNanos);
    }
}
Also used : ClientMessage(com.hazelcast.client.impl.protocol.ClientMessage) UUID(java.util.UUID) ScheduledExecutorGetStatsFromMemberCodec(com.hazelcast.client.impl.protocol.codec.ScheduledExecutorGetStatsFromMemberCodec) ScheduledTaskStatisticsImpl(com.hazelcast.scheduledexecutor.impl.ScheduledTaskStatisticsImpl)

Aggregations

ClientMessage (com.hazelcast.client.impl.protocol.ClientMessage)2 ScheduledTaskStatisticsImpl (com.hazelcast.scheduledexecutor.impl.ScheduledTaskStatisticsImpl)2 ScheduledExecutorGetStatsFromAddressCodec (com.hazelcast.client.impl.protocol.codec.ScheduledExecutorGetStatsFromAddressCodec)1 ScheduledExecutorGetStatsFromMemberCodec (com.hazelcast.client.impl.protocol.codec.ScheduledExecutorGetStatsFromMemberCodec)1 ClientInvocation (com.hazelcast.client.spi.impl.ClientInvocation)1 Address (com.hazelcast.nio.Address)1 StaleTaskException (com.hazelcast.scheduledexecutor.StaleTaskException)1 UUID (java.util.UUID)1 ExecutionException (java.util.concurrent.ExecutionException)1 TimeoutException (java.util.concurrent.TimeoutException)1