本文整理汇总了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());
}
});
}
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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);
}
示例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");
}
}
}
}
});
}
示例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);
}
}
示例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);
}
}
}
示例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());
}
示例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());
}
}
示例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());
}
}
示例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));
}
示例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));
}
示例15: getNodes
import org.infinispan.remoting.transport.Address; //导入依赖的package包/类
@Override
public List<String> getNodes() {
return cacheManager.getTransport().getMembers().stream().map(Address::toString).collect(toList());
}