private void createMemberState(MemberStateImpl memberState) {
   final Node node = factory.node;
   memberState.setAddress(node.getThisAddress());
   memberState.getMemberHealthStats().setOutOfMemory(node.isOutOfMemory());
   memberState.getMemberHealthStats().setActive(node.isActive());
   memberState
       .getMemberHealthStats()
       .setServiceThreadStats(node.getCpuUtilization().serviceThread);
   memberState.getMemberHealthStats().setOutThreadStats(node.getCpuUtilization().outThread);
   memberState.getMemberHealthStats().setInThreadStats(node.getCpuUtilization().inThread);
   PartitionService partitionService = factory.getPartitionService();
   Set<Partition> partitions = partitionService.getPartitions();
   memberState.clearPartitions();
   for (Partition partition : partitions) {
     if (partition.getOwner() != null && partition.getOwner().localMember()) {
       memberState.addPartition(partition.getPartitionId());
     }
   }
   Collection<HazelcastInstanceAwareInstance> proxyObjects =
       new ArrayList<HazelcastInstanceAwareInstance>(factory.getProxies());
   createMemState(memberState, proxyObjects.iterator(), InstanceType.MAP);
   createMemState(memberState, proxyObjects.iterator(), InstanceType.QUEUE);
   createMemState(memberState, proxyObjects.iterator(), InstanceType.TOPIC);
   createRuntimeProps(memberState);
   // uncomment when client changes are made
   // createMemState(memberState, proxyObjects.iterator(), InstanceType.ATOMIC_LONG);
   // createMemState(memberState, proxyObjects.iterator(), InstanceType.COUNT_DOWN_LATCH);
   // createMemState(memberState, proxyObjects.iterator(), InstanceType.SEMAPHORE);
 }
 @Test
 public void testNetworkConfig() {
   NetworkConfig networkConfig = config.getNetworkConfig();
   assertNotNull(networkConfig);
   assertEquals(5700, networkConfig.getPort());
   assertFalse(networkConfig.isPortAutoIncrement());
   final Collection<String> allowedPorts = networkConfig.getOutboundPortDefinitions();
   assertEquals(2, allowedPorts.size());
   Iterator portIter = allowedPorts.iterator();
   assertEquals("35000-35100", portIter.next());
   assertEquals("36000,36100", portIter.next());
   assertFalse(networkConfig.getJoin().getMulticastConfig().isEnabled());
   assertEquals(networkConfig.getJoin().getMulticastConfig().getMulticastTimeoutSeconds(), 8);
   assertEquals(networkConfig.getJoin().getMulticastConfig().getMulticastTimeToLive(), 16);
   assertFalse(networkConfig.getInterfaces().isEnabled());
   assertEquals(1, networkConfig.getInterfaces().getInterfaces().size());
   assertEquals("10.10.1.*", networkConfig.getInterfaces().getInterfaces().iterator().next());
   TcpIpConfig tcp = networkConfig.getJoin().getTcpIpConfig();
   assertNotNull(tcp);
   assertTrue(tcp.isEnabled());
   assertTrue(networkConfig.getSymmetricEncryptionConfig().isEnabled());
   final List<String> members = tcp.getMembers();
   assertEquals(members.toString(), 2, members.size());
   assertEquals("127.0.0.1:5700", members.get(0));
   assertEquals("127.0.0.1:5701", members.get(1));
   assertEquals("127.0.0.1:5700", tcp.getRequiredMember());
   AwsConfig aws = networkConfig.getJoin().getAwsConfig();
   assertFalse(aws.isEnabled());
   assertEquals("sample-access-key", aws.getAccessKey());
   assertEquals("sample-secret-key", aws.getSecretKey());
   assertEquals("sample-region", aws.getRegion());
   assertEquals("sample-group", aws.getSecurityGroupName());
   assertEquals("sample-tag-key", aws.getTagKey());
   assertEquals("sample-tag-value", aws.getTagValue());
 }
示例#3
0
  public Runnable prepareMergeRunnable() {
    Map<MapContainer, Collection<Record>> recordMap =
        new HashMap<MapContainer, Collection<Record>>(mapContainers.size());
    InternalPartitionService partitionService = nodeEngine.getPartitionService();
    int partitionCount = partitionService.getPartitionCount();
    Address thisAddress = nodeEngine.getClusterService().getThisAddress();

    for (MapContainer mapContainer : mapContainers.values()) {
      for (int i = 0; i < partitionCount; i++) {
        RecordStore recordStore = getPartitionContainer(i).getRecordStore(mapContainer.getName());
        // add your owned entries to the map so they will be merged
        if (thisAddress.equals(partitionService.getPartitionOwner(i))) {
          Collection<Record> records = recordMap.get(mapContainer);
          if (records == null) {
            records = new ArrayList<Record>();
            recordMap.put(mapContainer, records);
          }
          records.addAll(recordStore.getReadonlyRecordMap().values());
        }
        // clear all records either owned or backup
        recordStore.reset();
      }
    }
    return new Merger(recordMap);
  }
示例#4
0
 protected void handleMapValues() {
   Collection set = getMap().values();
   Iterator it = set.iterator();
   int count = 0;
   while (it.hasNext()) {
     count++;
     println(it.next());
   }
   println("Total " + count);
 }
示例#5
0
  @Test
  public void testAddAll() throws IOException {
    final int maxItems = 13;
    final IQueue q = client.getQueue(randomString());

    Collection coll = new ArrayList(maxItems);

    for (int i = 0; i < maxItems; i++) {
      coll.add(i);
    }

    assertTrue(q.addAll(coll));
    assertEquals(coll.size(), q.size());
  }
 private Set<String> getLongInstanceNames() {
   Set<String> setLongInstanceNames = new HashSet<String>(maxVisibleInstanceCount);
   Collection<HazelcastInstanceAwareInstance> proxyObjects =
       new ArrayList<HazelcastInstanceAwareInstance>(factory.getProxies());
   collectInstanceNames(setLongInstanceNames, proxyObjects.iterator(), InstanceType.MAP);
   collectInstanceNames(setLongInstanceNames, proxyObjects.iterator(), InstanceType.QUEUE);
   collectInstanceNames(setLongInstanceNames, proxyObjects.iterator(), InstanceType.TOPIC);
   // uncomment when client changes are made
   // collectInstanceNames(setLongInstanceNames, proxyObjects.iterator(),
   // InstanceType.ATOMIC_NUMBER);
   // collectInstanceNames(setLongInstanceNames, proxyObjects.iterator(),
   // InstanceType.COUNT_DOWN_LATCH);
   // collectInstanceNames(setLongInstanceNames, proxyObjects.iterator(), InstanceType.SEMAPHORE);
   return setLongInstanceNames;
 }
示例#7
0
 public void publishEvent(
     Address caller,
     String mapName,
     EntryEventType eventType,
     Data dataKey,
     Data dataOldValue,
     Data dataValue) {
   Collection<EventRegistration> candidates =
       nodeEngine.getEventService().getRegistrations(SERVICE_NAME, mapName);
   Set<EventRegistration> registrationsWithValue = new HashSet<EventRegistration>();
   Set<EventRegistration> registrationsWithoutValue = new HashSet<EventRegistration>();
   if (candidates.isEmpty()) return;
   Object key = null;
   Object value = null;
   Object oldValue = null;
   for (EventRegistration candidate : candidates) {
     EventFilter filter = candidate.getFilter();
     if (filter instanceof EventServiceImpl.EmptyFilter) {
       registrationsWithValue.add(candidate);
     } else if (filter instanceof QueryEventFilter) {
       Object testValue;
       if (eventType == EntryEventType.REMOVED || eventType == EntryEventType.EVICTED) {
         oldValue = oldValue != null ? oldValue : toObject(dataOldValue);
         testValue = oldValue;
       } else {
         value = value != null ? value : toObject(dataValue);
         testValue = value;
       }
       key = key != null ? key : toObject(dataKey);
       QueryEventFilter queryEventFilter = (QueryEventFilter) filter;
       QueryEntry entry = new QueryEntry(getSerializationService(), dataKey, key, testValue);
       if (queryEventFilter.eval(entry)) {
         if (queryEventFilter.isIncludeValue()) {
           registrationsWithValue.add(candidate);
         } else {
           registrationsWithoutValue.add(candidate);
         }
       }
     } else if (filter.eval(dataKey)) {
       EntryEventFilter eventFilter = (EntryEventFilter) filter;
       if (eventFilter.isIncludeValue()) {
         registrationsWithValue.add(candidate);
       } else {
         registrationsWithoutValue.add(candidate);
       }
     }
   }
   if (registrationsWithValue.isEmpty() && registrationsWithoutValue.isEmpty()) return;
   String source = nodeEngine.getThisAddress().toString();
   if (eventType == EntryEventType.REMOVED || eventType == EntryEventType.EVICTED) {
     dataValue = dataValue != null ? dataValue : dataOldValue;
   }
   EventData event =
       new EventData(
           source, mapName, caller, dataKey, dataValue, dataOldValue, eventType.getType());
   int orderKey = dataKey.hashCode();
   nodeEngine
       .getEventService()
       .publishEvent(SERVICE_NAME, registrationsWithValue, event, orderKey);
   nodeEngine
       .getEventService()
       .publishEvent(
           SERVICE_NAME, registrationsWithoutValue, event.cloneWithoutValues(), orderKey);
 }