use of org.jgroups.JChannel in project xwiki-platform by xwiki.
the class JGroupsNetworkAdapter method stopChannel.
@Override
public void stopChannel(String channelId) throws RemoteEventException {
JChannel channel = this.channels.get(channelId);
if (channel == null) {
throw new RemoteEventException(MessageFormat.format("Channel [{0}] is not started", channelId));
}
channel.close();
this.channels.remove(channelId);
// Unregister the channel from the JMX Server
try {
MBeanServer mbs = ManagementFactory.getPlatformMBeanServer();
JmxConfigurator.unregister(channel, mbs, channel.getClusterName());
} catch (Exception e) {
this.logger.warn("Failed to unregister channel [" + channelId + "] from the JMX Server", e);
}
this.logger.info("Channel [{}] stopped", channelId);
}
use of org.jgroups.JChannel in project keycloak by keycloak.
the class DistributedCacheWriteSkewTest method main.
public static void main(String[] args) throws Exception {
Cache<String, UserSessionEntity> cache1 = createManager("node1").getCache(InfinispanConnectionProvider.USER_SESSION_CACHE_NAME);
Cache<String, UserSessionEntity> cache2 = createManager("node2").getCache(InfinispanConnectionProvider.USER_SESSION_CACHE_NAME);
// Create initial item
UserSessionEntity session = new UserSessionEntity();
session.setId("123");
session.setRealmId("foo");
session.setBrokerSessionId("!23123123");
session.setBrokerUserId(null);
session.setUser("foo");
session.setLoginUsername("foo");
session.setIpAddress("123.44.143.178");
session.setStarted(Time.currentTime());
session.setLastSessionRefresh(Time.currentTime());
AuthenticatedClientSessionEntity clientSession = new AuthenticatedClientSessionEntity(UUID.randomUUID());
clientSession.setAuthMethod("saml");
clientSession.setAction("something");
clientSession.setTimestamp(1234);
session.getAuthenticatedClientSessions().put(CLIENT_1_UUID.toString(), clientSession.getId());
cache1.put("123", session);
// cache1.replace("123", session);
// Create 2 workers for concurrent write and start them
Worker worker1 = new Worker(1, cache1);
Worker worker2 = new Worker(2, cache2);
long start = System.currentTimeMillis();
System.out.println("Started clustering test");
worker1.start();
// worker1.join();
worker2.start();
worker1.join();
worker2.join();
long took = System.currentTimeMillis() - start;
session = cache1.get("123");
System.out.println("Took: " + took + " ms. Notes count: " + session.getNotes().size() + ", failedReplaceCounter: " + failedReplaceCounter.get());
// JGroups statistics
JChannel channel = (JChannel) ((JGroupsTransport) cache1.getAdvancedCache().getRpcManager().getTransport()).getChannel();
System.out.println("Sent MB: " + channel.getSentBytes() / 1000000 + ", sent messages: " + channel.getSentMessages() + ", received MB: " + channel.getReceivedBytes() / 1000000 + ", received messages: " + channel.getReceivedMessages());
// Kill JVM
cache1.stop();
cache2.stop();
cache1.getCacheManager().stop();
cache2.getCacheManager().stop();
System.out.println("Managers killed");
}
use of org.jgroups.JChannel in project keycloak by keycloak.
the class DistributedCacheConcurrentWritesTest method printStats.
private static void printStats(BasicCache cache) {
if (cache instanceof Cache) {
Cache cache1 = (Cache) cache;
JChannel channel = ((JGroupsTransport) cache1.getAdvancedCache().getRpcManager().getTransport()).getChannel();
System.out.println("Sent MB: " + channel.getSentBytes() / 1000000 + ", sent messages: " + channel.getSentMessages() + ", received MB: " + channel.getReceivedBytes() / 1000000 + ", received messages: " + channel.getReceivedMessages());
} else {
Map<String, String> stats = ((RemoteCache) cache).stats().getStatsMap();
System.out.println("Stats: " + stats);
}
}
use of org.jgroups.JChannel in project teiid by teiid.
the class SimpleChannelFactory method createChannel.
@Override
public Channel createChannel(String id) throws Exception {
synchronized (this) {
if (channel == null) {
channel = new JChannel(this.getClass().getClassLoader().getResource(this.embeddedConfiguration.getJgroupsConfigFile()));
// $NON-NLS-1$
channel.connect("teiid-replicator");
}
}
// assumes fork and other necessary protocols are in the main stack
// $NON-NLS-1$
ForkChannel fc = new ForkChannel(channel, "teiid-replicator-fork", id);
return fc;
}
use of org.jgroups.JChannel in project Intellij-Discord-Integration by Almighty-Alpaca.
the class DiscordIntegrationApplicationComponent method initComponent.
@Override
public synchronized void initComponent() {
try // Fixes problems that crashes JGroups if those two properties aren't properly set
{
Locale locale = Locale.getDefault();
if (System.getProperty("user.language") == null)
System.setProperty("user.language", locale.getLanguage());
if (System.getProperty("user.country") == null)
System.setProperty("user.country", locale.getCountry());
} catch (Exception e) {
e.printStackTrace();
}
try {
String props = "fast.xml";
LOG.trace("DiscordIntegrationApplicationComponent#initComponent()#props = {}", props);
JChannel channel = new JChannel(props);
channel.setReceiver(this);
this.channel = channel;
channel.connect("JetbrainsDiscordIntegration v" + JetbrainsDiscordIntegration.PROTOCOL_VERSION);
ReplicatedData data = new ReplicatedData(channel, this);
this.data = data;
this.instanceInfo = new InstanceInfo(channel.getAddressAsString(), ApplicationInfo.getInstance());
LOG.trace("DiscordIntegrationApplicationComponent#initComponent()#this.instanceInfo = {}", this.instanceInfo);
data.instanceAdd(System.currentTimeMillis(), this.instanceInfo);
RPC.updatePresence(2, TimeUnit.SECONDS);
} catch (Exception e) {
if (this.channel != null) {
this.channel.close();
this.channel = null;
}
if (this.data != null) {
this.data.close();
this.data = null;
}
RPC.dispose();
throw new RuntimeException(e);
}
MessageBus bus = ApplicationManager.getApplication().getMessageBus();
connection = bus.connect();
connection.subscribe(AppTopics.FILE_DOCUMENT_SYNC, new FileDocumentManagerListener());
connection.subscribe(FileEditorManagerListener.FILE_EDITOR_MANAGER, new FileEditorManagerListener());
EditorEventMulticaster multicaster = EditorFactory.getInstance().getEventMulticaster();
multicaster.addDocumentListener(this.documentListener = new DocumentListener());
multicaster.addEditorMouseListener(this.editorMouseListener = new EditorMouseListener());
checkExperiementalWindowListener();
VirtualFileManager.getInstance().addVirtualFileListener(this.virtualFileListener = new VirtualFileListener());
}
Aggregations