Search in sources :

Example 1 with ClientClusterService

use of com.hazelcast.client.impl.spi.ClientClusterService 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 ClientClusterService

use of com.hazelcast.client.impl.spi.ClientClusterService 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 ClientClusterService

use of com.hazelcast.client.impl.spi.ClientClusterService 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 4 with ClientClusterService

use of com.hazelcast.client.impl.spi.ClientClusterService in project hazelcast by hazelcast.

the class ClientClusterServiceMemberListTest method testLiteMembers.

@Test
public void testLiteMembers() {
    assertTrueEventually(() -> {
        final ClientClusterService clusterService = getClientClusterService(client);
        final Collection<Member> members = clusterService.getMembers(LITE_MEMBER_SELECTOR);
        verifyMembers(members, singletonList(liteInstance));
        assertEquals(1, clusterService.getMembers(LITE_MEMBER_SELECTOR).size());
    });
}
Also used : Member(com.hazelcast.cluster.Member) ClientClusterService(com.hazelcast.client.impl.spi.ClientClusterService) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 5 with ClientClusterService

use of com.hazelcast.client.impl.spi.ClientClusterService in project hazelcast by hazelcast.

the class ClientClusterServiceMemberListTest method testDataMembers.

@Test
public void testDataMembers() {
    assertTrueEventually(() -> {
        final ClientClusterService clusterService = getClientClusterService(client);
        final Collection<Member> members = clusterService.getMembers(DATA_MEMBER_SELECTOR);
        verifyMembers(members, asList(dataInstance, dataInstance2));
        assertEquals(2, clusterService.getMembers(DATA_MEMBER_SELECTOR).size());
    });
}
Also used : Member(com.hazelcast.cluster.Member) ClientClusterService(com.hazelcast.client.impl.spi.ClientClusterService) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Aggregations

ClientClusterService (com.hazelcast.client.impl.spi.ClientClusterService)5 Member (com.hazelcast.cluster.Member)4 HazelcastClientInstanceImpl (com.hazelcast.client.impl.clientside.HazelcastClientInstanceImpl)3 MCClusterMetadata (com.hazelcast.client.impl.management.MCClusterMetadata)3 Cluster (com.hazelcast.cluster.Cluster)3 HazelcastCommandLine.getHazelcastClientInstanceImpl (com.hazelcast.client.console.HazelcastCommandLine.getHazelcastClientInstanceImpl)2 ParallelJVMTest (com.hazelcast.test.annotation.ParallelJVMTest)2 QuickTest (com.hazelcast.test.annotation.QuickTest)2 AttributedStringBuilder (org.jline.utils.AttributedStringBuilder)2 Test (org.junit.Test)2 Util.idToString (com.hazelcast.jet.Util.idToString)1 Command (picocli.CommandLine.Command)1 HelpCommand (picocli.CommandLine.HelpCommand)1