use of com.hazelcast.cluster.Address in project hazelcast by hazelcast.
the class TcpClientConnectionTest method testWithLegalAndIllegalAddressTogether.
@Test
public void testWithLegalAndIllegalAddressTogether() {
String illegalAddress = randomString();
HazelcastInstance server = hazelcastFactory.newHazelcastInstance();
Address serverAddress = server.getCluster().getLocalMember().getAddress();
ClientConfig config = new ClientConfig();
config.setProperty(ClientProperty.SHUFFLE_MEMBER_LIST.getName(), "false");
config.getNetworkConfig().addAddress(illegalAddress).addAddress(serverAddress.getHost() + ":" + serverAddress.getPort());
HazelcastInstance client = hazelcastFactory.newHazelcastClient(config);
Collection<Client> connectedClients = server.getClientService().getConnectedClients();
assertEquals(connectedClients.size(), 1);
Client serverSideClientInfo = connectedClients.iterator().next();
assertEquals(serverSideClientInfo.getUuid(), client.getLocalEndpoint().getUuid());
}
use of com.hazelcast.cluster.Address in project hazelcast by hazelcast.
the class SystemLogPlugin method render.
private void render(DiagnosticsLogWriter writer, MembershipEvent event) {
switch(event.getEventType()) {
case MembershipEvent.MEMBER_ADDED:
writer.startSection("MemberAdded");
break;
case MembershipEvent.MEMBER_REMOVED:
writer.startSection("MemberRemoved");
break;
default:
return;
}
writer.writeKeyValueEntry("member", event.getMember().getAddress().toString());
// writing the members
writer.startSection("Members");
Set<Member> members = event.getMembers();
if (members != null) {
boolean first = true;
for (Member member : members) {
Address memberAddress = member.getAddress();
String addressStr = String.valueOf(memberAddress);
if (memberAddress.equals(thisAddress)) {
if (first) {
writer.writeEntry(addressStr + ":this:master");
} else {
writer.writeEntry(addressStr + ":this");
}
} else if (first) {
writer.writeEntry(addressStr + ":master");
} else {
writer.writeEntry(addressStr);
}
first = false;
}
}
writer.endSection();
// ending the outer section
writer.endSection();
}
use of com.hazelcast.cluster.Address in project hazelcast by hazelcast.
the class OperationHeartbeatPlugin method run.
@Override
public void run(DiagnosticsLogWriter writer) {
long nowMillis = System.currentTimeMillis();
for (Map.Entry<Address, AtomicLong> entry : heartbeatPerMember.entrySet()) {
Address member = entry.getKey();
long lastHeartbeatMillis = entry.getValue().longValue();
long noHeartbeatMillis = nowMillis - lastHeartbeatMillis;
float deviation = HUNDRED * ((float) (noHeartbeatMillis - expectedIntervalMillis)) / expectedIntervalMillis;
if (deviation >= maxDeviationPercentage) {
startLazyMainSection(writer);
writer.startSection("member" + member);
writer.writeKeyValueEntry("deviation(%)", deviation);
writer.writeKeyValueEntry("noHeartbeat(ms)", noHeartbeatMillis);
writer.writeKeyValueEntry("lastHeartbeat(ms)", lastHeartbeatMillis);
writer.writeKeyValueEntryAsDateTime("lastHeartbeat(date-time)", lastHeartbeatMillis);
writer.writeKeyValueEntry("now(ms)", nowMillis);
writer.writeKeyValueEntryAsDateTime("now(date-time)", nowMillis);
writer.endSection();
}
}
endLazyMainSection(writer);
}
use of com.hazelcast.cluster.Address in project hazelcast by hazelcast.
the class TimedMemberStateFactory method createTimedMemberState.
@Nonnull
public TimedMemberState createTimedMemberState() {
MemberStateImpl memberState = new MemberStateImpl();
Collection<StatisticsAwareService> services = instance.node.nodeEngine.getServices(StatisticsAwareService.class);
TimedMemberState timedMemberState = new TimedMemberState();
createMemberState(memberState, services);
timedMemberState.setMaster(instance.node.isMaster());
timedMemberState.setMemberList(new ArrayList<>());
Set<Member> memberSet = instance.getCluster().getMembers();
for (Member member : memberSet) {
MemberImpl memberImpl = (MemberImpl) member;
Address address = memberImpl.getAddress();
timedMemberState.getMemberList().add(address.getHost() + ":" + address.getPort());
}
timedMemberState.setMemberState(memberState);
timedMemberState.setClusterName(instance.getConfig().getClusterName());
SSLConfig sslConfig = getActiveMemberNetworkConfig(instance.getConfig()).getSSLConfig();
timedMemberState.setSslEnabled(sslConfig != null && sslConfig.isEnabled());
timedMemberState.setLite(instance.node.isLiteMember());
SocketInterceptorConfig interceptorConfig = getActiveMemberNetworkConfig(instance.getConfig()).getSocketInterceptorConfig();
timedMemberState.setSocketInterceptorEnabled(interceptorConfig != null && interceptorConfig.isEnabled());
ManagementCenterConfig managementCenterConfig = instance.node.getConfig().getManagementCenterConfig();
timedMemberState.setScriptingEnabled(managementCenterConfig.isScriptingEnabled());
timedMemberState.setConsoleEnabled(managementCenterConfig.isConsoleEnabled());
timedMemberState.setMcDataAccessEnabled(managementCenterConfig.isDataAccessEnabled());
return timedMemberState;
}
use of com.hazelcast.cluster.Address in project hazelcast by hazelcast.
the class InternalPartitionServiceImpl method triggerMasterToAssignPartitions.
/**
* Sends a {@link AssignPartitions} to the master to assign partitions.
*/
private void triggerMasterToAssignPartitions() {
if (!shouldTriggerMasterToAssignPartitions()) {
return;
}
ClusterServiceImpl clusterService = node.getClusterService();
ClusterState clusterState = clusterService.getClusterState();
if (!clusterState.isMigrationAllowed()) {
logger.warning("Partitions can't be assigned since cluster-state=" + clusterState);
return;
}
final Address masterAddress = latestMaster;
if (masterAddress == null || masterAddress.equals(node.getThisAddress())) {
return;
}
if (masterTriggered.compareAndSet(false, true)) {
OperationServiceImpl operationService = nodeEngine.getOperationService();
InvocationFuture<PartitionRuntimeState> future = operationService.invokeOnTarget(SERVICE_NAME, new AssignPartitions(), masterAddress);
future.whenCompleteAsync((partitionState, throwable) -> {
if (throwable == null) {
resetMasterTriggeredFlag();
if (partitionState != null) {
partitionState.setMaster(masterAddress);
processPartitionRuntimeState(partitionState);
}
} else {
resetMasterTriggeredFlag();
logger.severe(throwable);
}
});
masterTrigger.executeWithDelay();
}
}
Aggregations