Search in sources :

Example 21 with JChannel

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);
}
Also used : JChannel(org.jgroups.JChannel) RemoteEventException(org.xwiki.observation.remote.RemoteEventException) RemoteEventException(org.xwiki.observation.remote.RemoteEventException) ComponentLookupException(org.xwiki.component.manager.ComponentLookupException) IOException(java.io.IOException) MBeanServer(javax.management.MBeanServer)

Example 22 with JChannel

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");
}
Also used : AuthenticatedClientSessionEntity(org.keycloak.models.sessions.infinispan.entities.AuthenticatedClientSessionEntity) JChannel(org.jgroups.JChannel) UserSessionEntity(org.keycloak.models.sessions.infinispan.entities.UserSessionEntity)

Example 23 with JChannel

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);
    }
}
Also used : JChannel(org.jgroups.JChannel) JGroupsTransport(org.infinispan.remoting.transport.jgroups.JGroupsTransport) Cache(org.infinispan.Cache) RemoteCache(org.infinispan.client.hotrod.RemoteCache) BasicCache(org.infinispan.commons.api.BasicCache)

Example 24 with JChannel

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;
}
Also used : JChannel(org.jgroups.JChannel) ForkChannel(org.jgroups.fork.ForkChannel)

Example 25 with JChannel

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());
}
Also used : Locale(java.util.Locale) JChannel(org.jgroups.JChannel) ReplicatedData(com.almightyalpaca.jetbrains.plugins.discord.data.ReplicatedData) EditorEventMulticaster(com.intellij.openapi.editor.event.EditorEventMulticaster) InstanceInfo(com.almightyalpaca.jetbrains.plugins.discord.data.InstanceInfo) MessageBus(com.intellij.util.messages.MessageBus)

Aggregations

JChannel (org.jgroups.JChannel)119 GMS (org.jgroups.protocols.pbcast.GMS)22 NAKACK2 (org.jgroups.protocols.pbcast.NAKACK2)21 Protocol (org.jgroups.stack.Protocol)18 STABLE (org.jgroups.protocols.pbcast.STABLE)15 View (org.jgroups.View)14 Message (org.jgroups.Message)10 ArrayList (java.util.ArrayList)9 Address (org.jgroups.Address)7 IOException (java.io.IOException)6 Test (org.testng.annotations.Test)5 InetSocketAddress (java.net.InetSocketAddress)4 HashMap (java.util.HashMap)4 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)4 DistributedSystemDisconnectedException (org.apache.geode.distributed.DistributedSystemDisconnectedException)4 LockService (org.jgroups.blocks.locking.LockService)4 Test (org.junit.Test)4 BeforeMethod (org.testng.annotations.BeforeMethod)4 CountDownLatch (java.util.concurrent.CountDownLatch)3 ChannelBroadcastEndpointFactory (org.apache.activemq.artemis.api.core.ChannelBroadcastEndpointFactory)3