Search in sources :

Example 1 with MCClusterMetadata

use of com.hazelcast.client.impl.management.MCClusterMetadata in project hazelcast by hazelcast.

the class ClientConsoleApp method startPrompt.

private static String startPrompt(HazelcastInstance hz) {
    HazelcastClientInstanceImpl hazelcastClientImpl = getHazelcastClientInstanceImpl(hz);
    ClientClusterService clientClusterService = hazelcastClientImpl.getClientClusterService();
    MCClusterMetadata clusterMetadata = FutureUtil.getValue(getClusterMetadata(hazelcastClientImpl, clientClusterService.getMasterMember()));
    Cluster cluster = hazelcastClientImpl.getCluster();
    Set<Member> members = cluster.getMembers();
    String versionString = "Hazelcast " + clusterMetadata.getMemberVersion();
    return new StringBuilder().append("Hazelcast Console Application has started.\n").append("Connected to ").append(versionString).append(" at ").append(members.iterator().next().getAddress().toString()).append(" (+").append(members.size() - 1).append(" more)\n").append("Type 'help' for instructions").toString();
}
Also used : AttributedStringBuilder(org.jline.utils.AttributedStringBuilder) HazelcastClientInstanceImpl(com.hazelcast.client.impl.clientside.HazelcastClientInstanceImpl) HazelcastCommandLine.getHazelcastClientInstanceImpl(com.hazelcast.client.console.HazelcastCommandLine.getHazelcastClientInstanceImpl) Cluster(com.hazelcast.cluster.Cluster) Member(com.hazelcast.cluster.Member) ClientClusterService(com.hazelcast.client.impl.spi.ClientClusterService) MCClusterMetadata(com.hazelcast.client.impl.management.MCClusterMetadata)

Example 2 with MCClusterMetadata

use of com.hazelcast.client.impl.management.MCClusterMetadata in project hazelcast by hazelcast.

the class HazelcastCommandLine method cluster.

@Command(description = "Shows current cluster state and information about members")
public void cluster(@Mixin(name = "verbosity") Verbosity verbosity, @Mixin(name = "targets") TargetsMixin targets) {
    runWithHazelcast(targets, verbosity, false, hz -> {
        HazelcastClientInstanceImpl hazelcastClientImpl = getHazelcastClientInstanceImpl(hz);
        ClientClusterService clientClusterService = hazelcastClientImpl.getClientClusterService();
        MCClusterMetadata clusterMetadata = FutureUtil.getValue(getClusterMetadata(hazelcastClientImpl, clientClusterService.getMasterMember()));
        Cluster cluster = hazelcastClientImpl.getCluster();
        println("State: " + clusterMetadata.getCurrentState());
        println("Version: " + clusterMetadata.getMemberVersion());
        println("Size: " + cluster.getMembers().size());
        println("");
        String format = "%-24s %-19s";
        printf(format, "ADDRESS", "UUID");
        cluster.getMembers().forEach(member -> printf(format, member.getAddress(), member.getUuid()));
    });
}
Also used : HazelcastClientInstanceImpl(com.hazelcast.client.impl.clientside.HazelcastClientInstanceImpl) Cluster(com.hazelcast.cluster.Cluster) Util.idToString(com.hazelcast.jet.Util.idToString) ClientClusterService(com.hazelcast.client.impl.spi.ClientClusterService) MCClusterMetadata(com.hazelcast.client.impl.management.MCClusterMetadata) HelpCommand(picocli.CommandLine.HelpCommand) Command(picocli.CommandLine.Command)

Example 3 with MCClusterMetadata

use of com.hazelcast.client.impl.management.MCClusterMetadata in project hazelcast by hazelcast.

the class HazelcastCommandLine method getClusterMetadata.

protected static CompletableFuture<MCClusterMetadata> getClusterMetadata(HazelcastClientInstanceImpl client, Member member) {
    checkNotNull(member);
    ClientInvocation invocation = new ClientInvocation(client, MCGetClusterMetadataCodec.encodeRequest(), null, member.getUuid());
    return new ClientDelegatingFuture<>(invocation.invoke(), client.getSerializationService(), clientMessage -> {
        MCGetClusterMetadataCodec.ResponseParameters response = MCGetClusterMetadataCodec.decodeResponse(clientMessage);
        MCClusterMetadata metadata = new MCClusterMetadata();
        metadata.setCurrentState(ClusterState.getById(response.currentState));
        metadata.setClusterTime(response.clusterTime);
        metadata.setMemberVersion(response.memberVersion);
        return metadata;
    });
}
Also used : ClientDelegatingFuture(com.hazelcast.client.impl.ClientDelegatingFuture) ClientInvocation(com.hazelcast.client.impl.spi.impl.ClientInvocation) MCGetClusterMetadataCodec(com.hazelcast.client.impl.protocol.codec.MCGetClusterMetadataCodec) MCClusterMetadata(com.hazelcast.client.impl.management.MCClusterMetadata)

Example 4 with MCClusterMetadata

use of com.hazelcast.client.impl.management.MCClusterMetadata in project hazelcast by hazelcast.

the class SqlConsole method sqlStartingPrompt.

private static String sqlStartingPrompt(HazelcastInstance hz) {
    HazelcastClientInstanceImpl hazelcastClientImpl = getHazelcastClientInstanceImpl(hz);
    ClientClusterService clientClusterService = hazelcastClientImpl.getClientClusterService();
    MCClusterMetadata clusterMetadata = FutureUtil.getValue(getClusterMetadata(hazelcastClientImpl, clientClusterService.getMasterMember()));
    Cluster cluster = hazelcastClientImpl.getCluster();
    Set<Member> members = cluster.getMembers();
    String versionString = "Hazelcast " + clusterMetadata.getMemberVersion();
    return new AttributedStringBuilder().style(AttributedStyle.BOLD.foreground(PRIMARY_COLOR)).append("Connected to ").append(versionString).append(" at ").append(members.iterator().next().getAddress().toString()).append(" (+").append(String.valueOf(members.size() - 1)).append(" more)\n").append("Type 'help' for instructions").toAnsi();
}
Also used : HazelcastClientInstanceImpl(com.hazelcast.client.impl.clientside.HazelcastClientInstanceImpl) HazelcastCommandLine.getHazelcastClientInstanceImpl(com.hazelcast.client.console.HazelcastCommandLine.getHazelcastClientInstanceImpl) Cluster(com.hazelcast.cluster.Cluster) AttributedStringBuilder(org.jline.utils.AttributedStringBuilder) Member(com.hazelcast.cluster.Member) ClientClusterService(com.hazelcast.client.impl.spi.ClientClusterService) MCClusterMetadata(com.hazelcast.client.impl.management.MCClusterMetadata)

Example 5 with MCClusterMetadata

use of com.hazelcast.client.impl.management.MCClusterMetadata in project hazelcast by hazelcast.

the class GetClusterMetadataMessageTask method call.

@Override
protected Object call() throws Exception {
    MCClusterMetadata metadata = new MCClusterMetadata();
    metadata.setCurrentState(nodeEngine.getClusterService().getClusterState());
    metadata.setMemberVersion(BuildInfoProvider.getBuildInfo().getVersion());
    metadata.setClusterTime(nodeEngine.getClusterService().getClusterTime());
    return metadata;
}
Also used : MCClusterMetadata(com.hazelcast.client.impl.management.MCClusterMetadata)

Aggregations

MCClusterMetadata (com.hazelcast.client.impl.management.MCClusterMetadata)5 HazelcastClientInstanceImpl (com.hazelcast.client.impl.clientside.HazelcastClientInstanceImpl)3 ClientClusterService (com.hazelcast.client.impl.spi.ClientClusterService)3 Cluster (com.hazelcast.cluster.Cluster)3 HazelcastCommandLine.getHazelcastClientInstanceImpl (com.hazelcast.client.console.HazelcastCommandLine.getHazelcastClientInstanceImpl)2 Member (com.hazelcast.cluster.Member)2 AttributedStringBuilder (org.jline.utils.AttributedStringBuilder)2 ClientDelegatingFuture (com.hazelcast.client.impl.ClientDelegatingFuture)1 MCGetClusterMetadataCodec (com.hazelcast.client.impl.protocol.codec.MCGetClusterMetadataCodec)1 ClientInvocation (com.hazelcast.client.impl.spi.impl.ClientInvocation)1 Util.idToString (com.hazelcast.jet.Util.idToString)1 Command (picocli.CommandLine.Command)1 HelpCommand (picocli.CommandLine.HelpCommand)1