use of com.hazelcast.cluster.Cluster in project hazelcast by hazelcast.
the class HazelcastCommandLine method listJobs.
@Command(name = "list-jobs", description = "Lists running jobs on the cluster")
public void listJobs(@Mixin(name = "verbosity") Verbosity verbosity, @Mixin(name = "targets") TargetsMixin targets, @Option(names = { "-a", "--all" }, description = "Lists all jobs including completed and failed ones") boolean listAll) {
runWithHazelcast(targets, verbosity, false, hz -> {
JetClientInstanceImpl jetClientInstanceImpl = (JetClientInstanceImpl) hz.getJet();
List<JobSummary> summaries = jetClientInstanceImpl.getJobSummaryList();
String format = "%-19s %-18s %-23s %s";
printf(format, "ID", "STATUS", "SUBMISSION TIME", "NAME");
summaries.stream().filter(job -> listAll || isActive(job.getStatus())).forEach(job -> {
String idString = idToString(job.getJobId());
String name = job.getName().equals(idString) ? "N/A" : job.getName();
printf(format, idString, job.getStatus(), toLocalDateTime(job.getSubmissionTime()), name);
});
});
}
use of com.hazelcast.cluster.Cluster 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();
}
use of com.hazelcast.cluster.Cluster in project hazelcast by hazelcast.
the class ClientClusterProxyTest method removeMembershipListener.
@Test
public void removeMembershipListener() throws Exception {
Cluster cluster = client().getCluster();
UUID regId = cluster.addMembershipListener(new MembershipAdapter());
assertTrue(cluster.removeMembershipListener(regId));
}
use of com.hazelcast.cluster.Cluster in project hazelcast by hazelcast.
the class ClientRoundRobinLBTest method testRoundRobinLB_withMembers.
@Test
public void testRoundRobinLB_withMembers() {
RoundRobinLB roundRobinLB = new RoundRobinLB();
HazelcastInstance server = factory.newHazelcastInstance();
Cluster cluster = server.getCluster();
ClientConfig clientConfig = new ClientConfig();
clientConfig.setLoadBalancer(roundRobinLB);
roundRobinLB.init(cluster, clientConfig);
Member member = cluster.getLocalMember();
assertEquals(member, roundRobinLB.next());
assertEquals(member, roundRobinLB.nextDataMember());
}
Aggregations