当前位置: 首页>>代码示例>>Java>>正文


Java Address类代码示例

本文整理汇总了Java中org.infinispan.remoting.transport.Address的典型用法代码示例。如果您正苦于以下问题:Java Address类的具体用法?Java Address怎么用?Java Address使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


Address类属于org.infinispan.remoting.transport包,在下文中一共展示了Address类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: handleViewChangeInternal

import org.infinispan.remoting.transport.Address; //导入依赖的package包/类
private void handleViewChangeInternal(ViewChangedEvent e) {
  synchronized (InfinispanClusterManager.this) {
    if (!active) {
      return;
    }

    multimaps.forEach(InfinispanAsyncMultiMap::clearCache);

    List<Address> added = new ArrayList<>(e.getNewMembers());
    added.removeAll(e.getOldMembers());
    log.debug("Members added = " + added);
    added.forEach(address -> {
      if (nodeListener != null) {
        nodeListener.nodeAdded(address.toString());
      }
    });
    List<Address> removed = new ArrayList<>(e.getOldMembers());
    removed.removeAll(e.getNewMembers());
    log.debug("Members removed = " + removed);
    removed.forEach(address -> {
      if (nodeListener != null) {
        nodeListener.nodeLeft(address.toString());
      }
    });
  }
}
 
开发者ID:vert-x3,项目名称:vertx-infinispan,代码行数:27,代码来源:InfinispanClusterManager.java

示例2: addressToInetAddress

import org.infinispan.remoting.transport.Address; //导入依赖的package包/类
private InetAddress addressToInetAddress(Address a) {
    EmbeddedCacheManager manager = this.cm;
    if ((manager == null) || (a == null)) {
        // In case we cannot fetch the information, lets assume we
        // are standby, so to have less responsibility.
        return null;
    }
    Transport t = manager.getTransport();
    if (t instanceof JGroupsTransport) {
        JGroupsTransport jt = (JGroupsTransport) t;
        Channel c = jt.getChannel();
        if (a instanceof JGroupsAddress) {
            JGroupsAddress ja = (JGroupsAddress) a;
            org.jgroups.Address phys = (org.jgroups.Address) c
                    .down(new Event(Event.GET_PHYSICAL_ADDRESS, ja
                            .getJGroupsAddress()));
            if (phys instanceof org.jgroups.stack.IpAddress) {
                InetAddress bindAddress = ((org.jgroups.stack.IpAddress) phys)
                        .getIpAddress();
                return bindAddress;
            }
        }
    }
    return null;
}
 
开发者ID:lbchen,项目名称:ODL,代码行数:26,代码来源:ClusterManager.java

示例3: getClusteredControllers

import org.infinispan.remoting.transport.Address; //导入依赖的package包/类
@Override
public List<InetAddress> getClusteredControllers() {
    EmbeddedCacheManager manager = this.cm;
    if (manager == null) {
        return null;
    }
    List<Address> controllers = manager.getMembers();
    if ((controllers == null) || controllers.size() == 0) {
        return null;
    }

    List<InetAddress> clusteredControllers = new ArrayList<InetAddress>();
    for (Address a : controllers) {
        InetAddress inetAddress = addressToInetAddress(a);
        if (inetAddress != null
                && !inetAddress.getHostAddress().equals(loopbackAddress)) {
            clusteredControllers.add(inetAddress);
        }
    }
    return clusteredControllers;
}
 
开发者ID:lbchen,项目名称:ODL,代码行数:22,代码来源:ClusterManager.java

示例4: getKeysAddresses

import org.infinispan.remoting.transport.Address; //导入依赖的package包/类
public <K> Map<K, List<Address>> getKeysAddresses(Cache<K, Object> cache) {
    DistributionManager distributionManager = cache.getAdvancedCache().getDistributionManager();
    Map<K, List<Address>> response = new HashMap<>();
    for(K k : cache.keySet()) {
        response.put(k, distributionManager.locate(k));
    }
    return response;
}
 
开发者ID:redhat-italy,项目名称:hacep,代码行数:9,代码来源:JDGUtility.java

示例5: execute

import org.infinispan.remoting.transport.Address; //导入依赖的package包/类
@Override
public boolean execute(UI console, Iterator<String> args) throws IllegalParametersException {
    if (LOGGER.isDebugEnabled()) {
        LOGGER.debug("Start execute command 'sessions'");
    }

    Cache<String, Object> sessionCache = hacep.getSessionCache();
    Map<Address, List<SessionData>> sessions = new HashMap<>();
    hacep.getCacheManager().getMembers().forEach(a -> sessions.put(a, new ArrayList<>()));
    for (Map.Entry<String, List<Address>> entry : jdgUtility.getKeysAddresses(sessionCache).entrySet()) {
        if (LOGGER.isDebugEnabled()) {
            LOGGER.debug("Key [" + entry.getKey() + "] List{" + entry.getValue() + "}");
        }
        List<Address> addresses = entry.getValue() != null ? entry.getValue() : Collections.emptyList();
        for (int i = 0; i < addresses.size(); i++) {
            boolean isPrimary = (i == 0);
            if (LOGGER.isDebugEnabled()) {
                LOGGER.debug("Key [" + entry.getKey() + "] Address{" + addresses.get(i) + "] isPrimary [" + isPrimary + "]");
            }
            sessions.compute(addresses.get(i), (a, l) -> {
                SessionData object = new SessionData(entry.getKey().toString(), isPrimary ? NodeType.PRIMARY : NodeType.REPLICA);
                l.add(object);
                return l;
            });
        }
    }

    console.print(sessions.entrySet().stream()
            .map(e -> new HACEPNode(e.getKey().toString(), e.getValue()))
            .collect(Collectors.toList()));
    return true;
}
 
开发者ID:redhat-italy,项目名称:hacep,代码行数:33,代码来源:SessionsConsoleCommand.java

示例6: testMessage

import org.infinispan.remoting.transport.Address; //导入依赖的package包/类
/**
 * Simple messaging test.
 * 
 * @throws IOException
 * @throws InterruptedException
 * @throws ExecutionException
 * @throws TimeoutException
 */
@Test
public void testMessage() throws IOException, InterruptedException, ExecutionException, TimeoutException {
	final int nodeNumber = 3;
	
	// start test instance
	EmbeddedCacheManager cacheManager = new TestCacheManagerBuilder("node main", null).build();
	this.cacheManager = cacheManager;
	
	final Object monitor = new Object();
	final Map<Address, String> messages = Maps.newConcurrentMap();
	
	cacheManager.start();
	cacheManager.getCache(TestConstants.CACHE_DEFAULT).addListener(new NodeMessageListener<String>() {
		@Override
		public void onMessage(Message<String> value) {
			messages.put(value.getAddress(), value.getMessage());
			synchronized (monitor) {
				monitor.notify();
			}
		}
	});
	
	prepareCluster(nodeNumber, SimpleMessagingTask.class);
	
	// wait for n (n=nodeNumber) messages
	Callable<Boolean> test = new Callable<Boolean>() {
		@Override
		public Boolean call() throws Exception {
			return messages.keySet().size() >= nodeNumber;
		}
	};
	waitForEvent(monitor, test, 10, TimeUnit.SECONDS);
}
 
开发者ID:openwide-java,项目名称:owsi-core-parent,代码行数:42,代码来源:TestMessage.java

示例7: runTask

import org.infinispan.remoting.transport.Address; //导入依赖的package包/类
@Override
public void runTask() {
	// wait for a message from coordinator to try to lock keys A and B
	// post a message TimeoutException if lock cannot be acquired
	// post a message LockSuccess if lock is successful
	getCacheManager().getCache(TestConstants.CACHE_MESSAGE).addListener(new NodeMessageListener<String>() {
		@Override
		public void onMessage(Message<String> value) {
			LOGGER.debug("message received");
			if (value.getAddress().equals(getCacheManager().getCoordinator())) {
				LOGGER.debug("message received from coordinator");
				if ("tryLock".equals(value.getMessage())) {
					LOGGER.debug("received tryLock message");
					AdvancedCache<String, Object> cache =
							getCacheManager().<String, Object>getCache(TestConstants.CACHE_DEFAULT).getAdvancedCache();
					LOGGER.debug("batch started");
					cache.startBatch();
					boolean successful = false;
					Address address = getCacheManager().getAddress();
					try {
						LOGGER.debug("try A, B locks");
						cache.lock("A", "B");
						LOGGER.debug("lock successful");
						successful = true;
						LOGGER.debug("send success message");
						getCacheManager().<String, Message<String>>getCache(TestConstants.CACHE_MESSAGE)
							.put("messageBus", Message.from(address, LOCK_SUCCESS));
					} catch (TimeoutException e) {
						LOGGER.debug("send failure message");
						getCacheManager().<String, Message<String>>getCache(TestConstants.CACHE_MESSAGE)
							.put("messageBus", Message.from(address, TIMEOUT_EXCEPTION));
					} finally {
						cache.endBatch(successful);
						LOGGER.debug("batch ended");
					}
				}
			}
		}
	});
}
 
开发者ID:openwide-java,项目名称:owsi-core-parent,代码行数:41,代码来源:LockTask.java

示例8: viewChanged

import org.infinispan.remoting.transport.Address; //导入依赖的package包/类
/**
 * Triggered when a view is changed, signaling that a member has joined or dropped from the cluster.
 * @param event change details
 */
@ViewChanged
public void viewChanged(ViewChangedEvent event) {
    List<Address> dropped = new ArrayList<Address>(event.getOldMembers());
    dropped.removeAll(event.getNewMembers());
    for (Address addr : dropped) {
        dropAllServices(addr);
    }
}
 
开发者ID:jboss-switchyard,项目名称:switchyard,代码行数:13,代码来源:InfinispanRegistry.java

示例9: dropAllServices

import org.infinispan.remoting.transport.Address; //导入依赖的package包/类
void dropAllServices(Address address) {
    for (String node : _serviceCache.keySet()) {
        if (node.endsWith("/" + address.toString())) {
            _serviceCache.remove(node);
        }
    }
}
 
开发者ID:jboss-switchyard,项目名称:switchyard,代码行数:8,代码来源:InfinispanRegistry.java

示例10: compareTo

import org.infinispan.remoting.transport.Address; //导入依赖的package包/类
@Override
public int compareTo(Address address) {
    if (address == null) {
        return -1;
    }
    return _address.compareTo(address.toString());
}
 
开发者ID:jboss-switchyard,项目名称:switchyard,代码行数:8,代码来源:InfinispanRegistryTest.java

示例11: accept

import org.infinispan.remoting.transport.Address; //导入依赖的package包/类
@Override
public void accept(Address address, @Nullable Optional<V> value,
        @Nullable Throwable throwable) {
    if (throwable != null) {
        logger.warn("received error from {}: {}", address, throwable.getMessage(),
                throwable);
        logStackTrace = true;
        return;
    }
    // value is only null when throwable is not null
    if (checkNotNull(value).isPresent()) {
        values.add(value.get());
    }
}
 
开发者ID:glowroot,项目名称:glowroot,代码行数:15,代码来源:ClusterManager.java

示例12: viewChanged

import org.infinispan.remoting.transport.Address; //导入依赖的package包/类
@ViewChanged
public void viewChanged(ViewChangedEvent event) {
    log.debugf("view changed: %s", event);
    List<Address> old = new ArrayList<>(event.getOldMembers());
    old.removeAll(event.getNewMembers());
    for (Address address : old) {
        locksCache.remove(key, address.toString());
    }
}
 
开发者ID:hawkular,项目名称:hawkular-metrics,代码行数:10,代码来源:DistributedLock.java

示例13: primaryValuesFromKeys

import org.infinispan.remoting.transport.Address; //导入依赖的package包/类
public Set<String> primaryValuesFromKeys(Cache<Key, Object> cache) {
    DistributionManager distributionManager = cache.getAdvancedCache().getDistributionManager();
    Address address = cache.getCacheManager().getAddress();
    return valuesFromKeys(cache, k -> distributionManager.getPrimaryLocation(k).equals(address));
}
 
开发者ID:redhat-italy,项目名称:hacep,代码行数:6,代码来源:JDGUtility.java

示例14: replicaValuesFromKeys

import org.infinispan.remoting.transport.Address; //导入依赖的package包/类
public Set<String> replicaValuesFromKeys(Cache<Key, Object> cache) {
    DistributionManager distributionManager = cache.getAdvancedCache().getDistributionManager();
    Address address = cache.getCacheManager().getAddress();
    return valuesFromKeys(cache, k -> distributionManager.getLocality(k).isLocal() && !distributionManager.getPrimaryLocation(k).equals(address));
}
 
开发者ID:redhat-italy,项目名称:hacep,代码行数:6,代码来源:JDGUtility.java

示例15: getNodes

import org.infinispan.remoting.transport.Address; //导入依赖的package包/类
@Override
public List<String> getNodes() {
  return cacheManager.getTransport().getMembers().stream().map(Address::toString).collect(toList());
}
 
开发者ID:vert-x3,项目名称:vertx-infinispan,代码行数:5,代码来源:InfinispanClusterManager.java


注:本文中的org.infinispan.remoting.transport.Address类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。