Java 类com.hazelcast.core.DistributedObject 实例源码

项目:bagri    文件:ClientManagementImpl.java   
private boolean removeClient(String clientId) {
    String qName = "client:" + clientId;
    boolean removed = false;
    java.util.Collection<DistributedObject> all = hzInstance.getDistributedObjects();
    int sizeBefore = all.size();
    for (DistributedObject obj: all) {
        if (qName.equals(obj.getName()) && QueueService.SERVICE_NAME.equals(obj.getServiceName())) {
            // remove queue
            obj.destroy();
            removed = true;
            break;
        }
    }
    int sizeAfter = hzInstance.getDistributedObjects().size(); 
    logger.debug("removeClient.exit; queue {} {} for client: {}; size before: {}, after: {}", 
            qName, removed ? "destroyed" : "skipped", clientId, sizeBefore, sizeAfter); 
    return removed;
}
项目:spring-data-hazelcast    文件:TestDataHelper.java   
@After
public void tearDown() {
    for (String mapName : TestConstants.OSCAR_MAP_NAMES) {
        IMap<String, ?> iMap = this.hazelcastInstance.getMap(mapName);
        iMap.clear();
    }

    checkMapsEmpty("tearDown");

    Collection<DistributedObject> distributedObjects = this.hazelcastInstance.getDistributedObjects();

    for (DistributedObject distributedObject : distributedObjects) {
        assertThat(distributedObject.getName(), distributedObject, instanceOf(IMap.class));
        assertThat(distributedObject.getName(), isIn(TestConstants.OSCAR_MAP_NAMES));
    }

    assertThat("Correct number of distributed objects",
            distributedObjects.size(), equalTo(TestConstants.OSCAR_MAP_NAMES.length));

}
项目:hazelcast-simulator    文件:AtomicLongTest.java   
@Verify
public void verify() {
    String serviceName = totalCounter.getServiceName();
    String totalName = totalCounter.getName();

    long actual = 0;
    for (DistributedObject distributedObject : targetInstance.getDistributedObjects()) {
        String key = distributedObject.getName();
        if (serviceName.equals(distributedObject.getServiceName())
                && key.startsWith(name)
                && !key.equals(totalName)) {
            actual += targetInstance.getAtomicLong(key).get();
        }
    }

    assertEquals(totalCounter.get(), actual);
}
项目:hazelcast-shell-spring-boot-starter    文件:HazelcastService.java   
public List<String> getMapNames() {

        return hazelcastInstance
                .getDistributedObjects()
                .stream()
                .filter(e -> e.getServiceName().equals(MapService.SERVICE_NAME))
                .map(DistributedObject::getName)
                .collect(Collectors.toList());
    }
项目:cms    文件:HazelcastDistributedCacheManager.java   
public void clearAllCaches(){
    final Collection<DistributedObject> distributedObjects = hazelcastInstance.getDistributedObjects();
    for (DistributedObject distributedObject : distributedObjects) {
        if (distributedObject instanceof IMap) {
            final IMap<?, ?> map = (IMap) distributedObject;
            map.clear();
        }
    }
}
项目:cms    文件:HazelcastDistributedCacheManager.java   
public void clearAllCachesExcept(List<String> cacheRegions){
    final Collection<DistributedObject> distributedObjects = hazelcastInstance.getDistributedObjects();
    for (DistributedObject distributedObject : distributedObjects) {
        if (distributedObject instanceof IMap) {
            final IMap<?, ?> map = (IMap) distributedObject;
            String region = map.getName();
            boolean exists = cacheRegions.stream().filter(s->region.contains(s)).count()>0;
            if(!exists) {
                map.clear();
            }
        }
    }
}
项目:eet.osslite.cz    文件:HazelcastAdminRest.java   
@RequestMapping(method = RequestMethod.GET)
public ResponseEntity<?> read(@RequestBody(required = false) String input) {

    StringBuilder sb = new StringBuilder();
    sb.append("{");

    for (HazelcastInstance hazelInst : Hazelcast.getAllHazelcastInstances()) {
        Iterator<Member> iter = hazelInst.getCluster().getMembers().iterator();
        while (iter.hasNext()) {
            sb.append("\"member\": \"");
            sb.append(iter.next().getAddress());
            sb.append("\"");
        }
        sb.append(",\"name\": \"");
        sb.append(hazelInst.getName());
        sb.append("\"");

        // IMap map = hz.getMap( "test" );
        Collection<DistributedObject> objects = hazelInst.getDistributedObjects();
        for (DistributedObject distributedObject : objects) {
            if (distributedObject instanceof IMap) {
                sb.append(",\"mapName\": \"");
                sb.append(distributedObject.getName());
                sb.append("\"");
            }
        }
    }

    sb.append("}");

    return ResponseEntity.ok(sb.toString());
}
项目:hybridbpm    文件:HazelcastServer.java   
public static void sendDashboardNotificationEventIfExists(DashboardNotificationEvent dashboardNotificationEvent) {
    Collection<DistributedObject> instances = hazelcastInstance.getDistributedObjects();
    for (DistributedObject instance : instances) {
        if (instance.getServiceName().equals("hz:impl:topicService") && instance.getName().equals(dashboardNotificationEvent.getReceiverName())) {
            sendDashboardNotificationEvent(dashboardNotificationEvent);
        }
    }
}
项目:datacafe    文件:HzClient.java   
/**
 * Reads an entry from the multi-map
 * invoke: HzClient.readValuesFromMultiMap("my-distributed-map", "sample-key");
 *
 * @return the values of the entry.
 */
public static Collection<DistributedObject> getDistributedObjects() {
    Collection<DistributedObject> distributedObjects = clientInstance.getDistributedObjects();

    for (DistributedObject distributedObject: distributedObjects) {
        logger.info(distributedObject.getName());
    }
    return distributedObjects;
}
项目:sakai    文件:HazelcastMemoryService.java   
@Override
public Iterable<String> getCacheNames() {
    if (this.hcInstance != null) {
        Collection<DistributedObject> distributedObjects = hcInstance.getDistributedObjects();
        ArrayList<String> names = new ArrayList<String>(distributedObjects.size());
        for (DistributedObject distributedObject : distributedObjects) {
            names.add(distributedObject.getName());
        }
        return names;
    } else {
        return new ArrayList<String>(0);
    }
}
项目:sakai    文件:HazelcastMemoryService.java   
@Override
public void resetCachers() {
    if (!getSecurityService().isSuperUser()) {
        throw new SecurityException("Only super admin can reset cachers, current user not super admin");
    }
    if (this.hcInstance != null) {
        Collection<DistributedObject> distributedObjects = hcInstance.getDistributedObjects();
        for (DistributedObject distributedObject : distributedObjects) {
            if (distributedObject instanceof IMap) {
                ((IMap)distributedObject).clear();
            }
        }
    }
}
项目:bagri    文件:ResultCursorTest.java   
private boolean findDistributedObject(String serviceName, String objectName) {
    HazelcastInstance hzi = ((SchemaRepositoryImpl) xRepo).getHzInstance();
    for (DistributedObject svc: hzi.getDistributedObjects()) {
        if (objectName.equals(svc.getName())) {
            if (serviceName == null) {
                return true;
            } else if (serviceName.equals(svc.getServiceName())) {
                return true;
            }
        }
    }
    return false;
}
项目:sakai    文件:HazelcastMemoryService.java   
@Override
public Iterable<String> getCacheNames() {
    if (this.hcInstance != null) {
        Collection<DistributedObject> distributedObjects = hcInstance.getDistributedObjects();
        ArrayList<String> names = new ArrayList<String>(distributedObjects.size());
        for (DistributedObject distributedObject : distributedObjects) {
            names.add(distributedObject.getName());
        }
        return names;
    } else {
        return new ArrayList<String>(0);
    }
}
项目:sakai    文件:HazelcastMemoryService.java   
@Override
public void resetCachers() {
    if (!getSecurityService().isSuperUser()) {
        throw new SecurityException("Only super admin can reset cachers, current user not super admin");
    }
    if (this.hcInstance != null) {
        Collection<DistributedObject> distributedObjects = hcInstance.getDistributedObjects();
        for (DistributedObject distributedObject : distributedObjects) {
            if (distributedObject instanceof IMap) {
                ((IMap)distributedObject).clear();
            }
        }
    }
}
项目:spring-data-hazelcast    文件:TestDataHelper.java   
@Before
public void setUp() {
    assertThat("Correct Hazelcast instance", this.hazelcastInstance.getName(),
            equalTo(Constants.HAZELCAST_INSTANCE_NAME));

    checkMapsEmpty("setUp");

    this.makeupMap = this.hazelcastInstance.getMap(TestConstants.MAKEUP_MAP_NAME);
    loadMakeup(this.makeupMap);

    this.movieMap = this.hazelcastInstance.getMap(TestConstants.MOVIE_MAP_NAME);
    loadMovie(this.movieMap);

    this.personMap = this.hazelcastInstance.getMap(TestConstants.PERSON_MAP_NAME);
    loadPerson(this.personMap);

    this.songMap = this.hazelcastInstance.getMap(TestConstants.SONG_MAP_NAME);
    loadSong(this.songMap);

    checkMapsNotEmpty("setUp");

    /* As Hazelcast will create objects on demand, check no more are present
     * than should be.
     */
    Collection<DistributedObject> distributedObjects = this.hazelcastInstance.getDistributedObjects();
    assertThat("Correct number of distributed objects",
            distributedObjects.size(), equalTo(TestConstants.OSCAR_MAP_NAMES.length));
}
项目:hazelcast-simulator    文件:AsyncAtomicLongTest.java   
@Verify
public void verify() {
    if (isClient(targetInstance)) {
        return;
    }

    final String serviceName = totalCounter.getServiceName();
    final long expected = totalCounter.get();

    // since the operations are asynchronous, we have no idea when they complete
    assertTrueEventually(new AssertTask() {
        @Override
        public void run() throws Exception {
            // hack to prevent overloading the system with get calls, else it is done many times a second
            sleepSeconds(10);

            long actual = 0;
            for (DistributedObject distributedObject : targetInstance.getDistributedObjects()) {
                String key = distributedObject.getName();
                if (serviceName.equals(distributedObject.getServiceName()) && key.startsWith(name)) {
                    actual += targetInstance.getAtomicLong(key).get();
                }
            }

            assertEquals(expected, actual);
        }
    }, assertEventuallySeconds);
}
项目:lb-axon    文件:DynamicSubscriber.java   
@Override
public void subscribe(final HazelcastInstance hzInstance,final HzEventBusTerminal terminal) {
    m_hzInstance = hzInstance;
    m_terminal   = terminal;

    if(m_terminal != null && m_hzInstance != null) {
        m_hzInstance.addDistributedObjectListener(this);
    }

    for(DistributedObject object : m_hzInstance.getDistributedObjects()) {
        if(object instanceof ITopic) {
            subscribeTopic(object);
        }
    }
}
项目:lb-axon    文件:DynamicSubscriber.java   
@Override
public void unsubscribe(final HazelcastInstance hzInstance,final HzEventBusTerminal terminal) {
    for(DistributedObject object : hzInstance.getDistributedObjects()) {
        if(object instanceof ITopic) {
            unsubscribeTopic(object);
        }
    }

    m_hzInstance = null;
    m_terminal   = null;
}
项目:lb-axon    文件:DynamicSubscriber.java   
@Override
@SuppressWarnings("uncheked")
public void distributedObjectCreated(DistributedObjectEvent event) {
    DistributedObject object = event.getDistributedObject();
    if(object instanceof ITopic) {
        subscribeTopic(object);
    }
}
项目:lb-axon    文件:DynamicSubscriber.java   
@Override
@SuppressWarnings("uncheked")
public void distributedObjectDestroyed(DistributedObjectEvent event) {
    DistributedObject object = event.getDistributedObject();
    if(object instanceof ITopic) {
        unsubscribeTopic(object);
    }
}
项目:lb-axon    文件:DynamicSubscriber.java   
/**
 *
 * @param object the objects
 */
@SuppressWarnings("unchecked")
private void subscribeTopic(DistributedObject object) {
    String name = object.getName();
    for(String topicName : m_topicNames) {
        if(name.matches(topicName)) {
            LOGGER.debug("Subscribing to <{}>",name);
            m_subKeys.put(
                topicName,
                ((ITopic<EventMessage>) object).addMessageListener(m_terminal));
        }
    }
}
项目:lb-axon    文件:DynamicSubscriber.java   
/**
 *
 * @param object the objects
 */
@SuppressWarnings("unchecked")
private void unsubscribeTopic(DistributedObject object) {
    String name = object.getName();
    for(String topicName : m_topicNames) {
        if(name.matches(topicName)) {
            LOGGER.debug("Unsubscribing from <{}>",name);

            String key = m_subKeys.remove(topicName);
            if(StringUtils.isNotEmpty(key)) {
                ((ITopic<EventMessage>)object).removeMessageListener(key);
            }
        }
    }
}
项目:xm-ms-entity    文件:WebConfigurerIntTest.java   
@Override
public Collection<DistributedObject> getDistributedObjects() {
    return null;
}
项目:xm-ms-entity    文件:WebConfigurerIntTest.java   
@Override
public <T extends DistributedObject> T getDistributedObject(String s, String s1) {
    return null;
}
项目:ratelimitj    文件:HazelcastSlidingWindowSyncRequestRequestRateLimiterPerformanceTest.java   
@AfterEach
void afterEach() {
    hz.getDistributedObjects().forEach(DistributedObject::destroy);
}
项目:ratelimitj    文件:HazelcastRequestRateLimiterInternalTest.java   
@AfterEach
void afterEach() {
    hz.getDistributedObjects().forEach(DistributedObject::destroy);
}
项目:ratelimitj    文件:HazelcastSlidingWindowSyncRequestRateLimiterTest.java   
@AfterEach
void afterEach() {
    hz.getDistributedObjects().forEach(DistributedObject::destroy);
}
项目:snowcast    文件:NodeSequencerService.java   
@Nonnull
@Override
public DistributedObject createDistributedObject(@Nonnull String objectName) {
    return new DummyProxy(objectName);
}
项目:hazelcast-modules    文件:TreeSetService.java   
@Override
public DistributedObject createDistributedObject(String objectId) {
    return new TreeSetProxyImpl(objectId, nodeEngine, this);
}
项目:hazel-local-cache    文件:LocalCacheService.java   
@Override
public DistributedObject createDistributedObject(String objectName) {
    return new LocalCacheProxy(objectName, nodeEngine, this);
}
项目:Cherry    文件:HazelcastService.java   
@Override
public Collection<DistributedObject> getDistributedObjects() {
  return getHazelcastInstance().getDistributedObjects();
}
项目:Cherry    文件:HazelcastService.java   
@Override
public <T extends DistributedObject> T getDistributedObject(final String serviceName, final Object id) {
  throw new DeprecatedError();
}
项目:Cherry    文件:HazelcastService.java   
@Override
public <T extends DistributedObject> T getDistributedObject(final String serviceName, final String name) {
  return getHazelcastInstance().getDistributedObject(serviceName, name);
}