本文整理汇总了Java中com.hazelcast.core.DistributedObject类的典型用法代码示例。如果您正苦于以下问题:Java DistributedObject类的具体用法?Java DistributedObject怎么用?Java DistributedObject使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
DistributedObject类属于com.hazelcast.core包,在下文中一共展示了DistributedObject类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: removeClient
import com.hazelcast.core.DistributedObject; //导入依赖的package包/类
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;
}
示例2: tearDown
import com.hazelcast.core.DistributedObject; //导入依赖的package包/类
@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));
}
示例3: verify
import com.hazelcast.core.DistributedObject; //导入依赖的package包/类
@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);
}
示例4: getMapNames
import com.hazelcast.core.DistributedObject; //导入依赖的package包/类
public List<String> getMapNames() {
return hazelcastInstance
.getDistributedObjects()
.stream()
.filter(e -> e.getServiceName().equals(MapService.SERVICE_NAME))
.map(DistributedObject::getName)
.collect(Collectors.toList());
}
示例5: clearAllCaches
import com.hazelcast.core.DistributedObject; //导入依赖的package包/类
public void clearAllCaches(){
final Collection<DistributedObject> distributedObjects = hazelcastInstance.getDistributedObjects();
for (DistributedObject distributedObject : distributedObjects) {
if (distributedObject instanceof IMap) {
final IMap<?, ?> map = (IMap) distributedObject;
map.clear();
}
}
}
示例6: clearAllCachesExcept
import com.hazelcast.core.DistributedObject; //导入依赖的package包/类
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();
}
}
}
}
示例7: read
import com.hazelcast.core.DistributedObject; //导入依赖的package包/类
@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());
}
示例8: sendDashboardNotificationEventIfExists
import com.hazelcast.core.DistributedObject; //导入依赖的package包/类
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);
}
}
}
示例9: getDistributedObjects
import com.hazelcast.core.DistributedObject; //导入依赖的package包/类
/**
* 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;
}
示例10: getCacheNames
import com.hazelcast.core.DistributedObject; //导入依赖的package包/类
@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);
}
}
示例11: resetCachers
import com.hazelcast.core.DistributedObject; //导入依赖的package包/类
@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();
}
}
}
}
示例12: findDistributedObject
import com.hazelcast.core.DistributedObject; //导入依赖的package包/类
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;
}
示例13: setUp
import com.hazelcast.core.DistributedObject; //导入依赖的package包/类
@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));
}
示例14: verify
import com.hazelcast.core.DistributedObject; //导入依赖的package包/类
@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);
}
示例15: subscribe
import com.hazelcast.core.DistributedObject; //导入依赖的package包/类
@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);
}
}
}