Search in sources :

Example 26 with MemberImpl

use of com.hazelcast.cluster.impl.MemberImpl in project hazelcast by hazelcast.

the class TransactionManagerServiceImpl method pickBackupLogAddresses.

Address[] pickBackupLogAddresses(int durability) {
    if (durability == 0) {
        return EMPTY_ADDRESSES;
    }
    // This should be cleaned up because this is quite a complex approach since it depends on
    // the number of members in the cluster and creates litter.
    ClusterService clusterService = nodeEngine.getClusterService();
    List<MemberImpl> members = new ArrayList<>(clusterService.getMemberImpls());
    members.remove(nodeEngine.getLocalMember());
    int c = Math.min(members.size(), durability);
    shuffle(members);
    Address[] addresses = new Address[c];
    for (int i = 0; i < c; i++) {
        addresses[i] = members.get(i).getAddress();
    }
    return addresses;
}
Also used : ClusterService(com.hazelcast.internal.cluster.ClusterService) Address(com.hazelcast.cluster.Address) MemberImpl(com.hazelcast.cluster.impl.MemberImpl) ArrayList(java.util.ArrayList)

Example 27 with MemberImpl

use of com.hazelcast.cluster.impl.MemberImpl 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;
}
Also used : SSLConfig(com.hazelcast.config.SSLConfig) StatisticsAwareService(com.hazelcast.internal.services.StatisticsAwareService) Address(com.hazelcast.cluster.Address) SocketInterceptorConfig(com.hazelcast.config.SocketInterceptorConfig) MemberStateImpl(com.hazelcast.internal.monitor.impl.MemberStateImpl) MemberImpl(com.hazelcast.cluster.impl.MemberImpl) ManagementCenterConfig(com.hazelcast.config.ManagementCenterConfig) Member(com.hazelcast.cluster.Member) CPMember(com.hazelcast.cp.CPMember) Nonnull(javax.annotation.Nonnull)

Example 28 with MemberImpl

use of com.hazelcast.cluster.impl.MemberImpl in project hazelcast by hazelcast.

the class CacheSerializationTest method testCachePartitionEventData.

@Test
public void testCachePartitionEventData() throws UnknownHostException {
    Address address = new Address("127.0.0.1", 5701);
    Member member = new MemberImpl(address, MemberVersion.UNKNOWN, true);
    CachePartitionEventData cachePartitionEventData = new CachePartitionEventData("test", 1, member);
    CachePartitionEventData deserialized = service.toObject(cachePartitionEventData);
    assertEquals(cachePartitionEventData, deserialized);
}
Also used : CachePartitionEventData(com.hazelcast.cache.impl.CachePartitionEventData) Address(com.hazelcast.cluster.Address) MemberImpl(com.hazelcast.cluster.impl.MemberImpl) Member(com.hazelcast.cluster.Member) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 29 with MemberImpl

use of com.hazelcast.cluster.impl.MemberImpl in project hazelcast by hazelcast.

the class MapPublisherCreateWithValueMessageTask method createPublishersAndGetSnapshotOf.

private List<Future> createPublishersAndGetSnapshotOf(Collection<MemberImpl> members) {
    List<Future> futures = new ArrayList<Future>(members.size());
    OperationServiceImpl operationService = nodeEngine.getOperationService();
    for (MemberImpl member : members) {
        Predicate predicate = serializationService.toObject(parameters.predicate);
        AccumulatorInfo accumulatorInfo = AccumulatorInfo.toAccumulatorInfo(parameters.mapName, parameters.cacheName, predicate, parameters.batchSize, parameters.bufferSize, parameters.delaySeconds, true, parameters.populate, parameters.coalesce);
        PublisherCreateOperation operation = new PublisherCreateOperation(accumulatorInfo);
        operation.setCallerUuid(endpoint.getUuid());
        Address address = member.getAddress();
        InvocationBuilder invocationBuilder = operationService.createInvocationBuilder(SERVICE_NAME, operation, address);
        Future future = invocationBuilder.invoke();
        futures.add(future);
    }
    return futures;
}
Also used : Address(com.hazelcast.cluster.Address) MemberImpl(com.hazelcast.cluster.impl.MemberImpl) ArrayList(java.util.ArrayList) Future(java.util.concurrent.Future) AccumulatorInfo(com.hazelcast.map.impl.querycache.accumulator.AccumulatorInfo) InvocationBuilder(com.hazelcast.spi.impl.operationservice.InvocationBuilder) PublisherCreateOperation(com.hazelcast.map.impl.querycache.subscriber.operation.PublisherCreateOperation) OperationServiceImpl(com.hazelcast.spi.impl.operationservice.impl.OperationServiceImpl) Predicate(com.hazelcast.query.Predicate)

Example 30 with MemberImpl

use of com.hazelcast.cluster.impl.MemberImpl in project hazelcast by hazelcast.

the class MapPublisherCreateWithValueMessageTask method call.

@Override
protected Object call() throws Exception {
    ClusterService clusterService = clientEngine.getClusterService();
    Collection<MemberImpl> members = clusterService.getMemberImpls();
    List<Future> snapshotFutures = createPublishersAndGetSnapshotOf(members);
    return fetchMapSnapshotFrom(snapshotFutures);
}
Also used : ClusterService(com.hazelcast.internal.cluster.ClusterService) MemberImpl(com.hazelcast.cluster.impl.MemberImpl) Future(java.util.concurrent.Future)

Aggregations

MemberImpl (com.hazelcast.cluster.impl.MemberImpl)123 Address (com.hazelcast.cluster.Address)41 Test (org.junit.Test)37 QuickTest (com.hazelcast.test.annotation.QuickTest)34 ParallelJVMTest (com.hazelcast.test.annotation.ParallelJVMTest)32 Member (com.hazelcast.cluster.Member)21 HazelcastInstance (com.hazelcast.core.HazelcastInstance)16 UUID (java.util.UUID)14 ArrayList (java.util.ArrayList)10 MemberInfo (com.hazelcast.internal.cluster.MemberInfo)9 HashMap (java.util.HashMap)9 InetAddress (java.net.InetAddress)8 HashSet (java.util.HashSet)8 ClusterService (com.hazelcast.internal.cluster.ClusterService)7 Config (com.hazelcast.config.Config)6 Future (java.util.concurrent.Future)6 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)5 StaticMemberNodeContext (com.hazelcast.instance.StaticMemberNodeContext)4 HazelcastInstanceFactory.newHazelcastInstance (com.hazelcast.instance.impl.HazelcastInstanceFactory.newHazelcastInstance)4 MembersUpdateOp (com.hazelcast.internal.cluster.impl.operations.MembersUpdateOp)4