Skip to content

Commit

Permalink
TEIID-5476 moving the jgroups dependency to jboss-integration
Browse files Browse the repository at this point in the history
  • Loading branch information
shawkins committed Nov 21, 2018
1 parent 12d5dc9 commit 8777022
Show file tree
Hide file tree
Showing 20 changed files with 155 additions and 99 deletions.
4 changes: 4 additions & 0 deletions jboss-integration/pom.xml
Expand Up @@ -72,6 +72,10 @@
<dependency>
<groupId>org.wildfly</groupId>
<artifactId>wildfly-clustering-jgroups-spi</artifactId>
</dependency>
<dependency>
<groupId>org.jgroups</groupId>
<artifactId>jgroups</artifactId>
</dependency>
<dependency>
<groupId>org.wildfly</groupId>
Expand Down
Expand Up @@ -27,7 +27,6 @@
import org.teiid.deployers.VDBRepository;
import org.teiid.dqp.internal.process.DQPCore;
import org.teiid.runtime.MaterializationManager;
import org.teiid.runtime.NodeTracker;

class MaterializationManagementService implements Service<MaterializationManager> {
private ScheduledExecutorService scheduler;
Expand Down
Expand Up @@ -15,7 +15,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.teiid.runtime;
package org.teiid.jboss;

import java.util.Collections;
import java.util.HashMap;
Expand All @@ -32,13 +32,12 @@
import org.jgroups.View;
import org.teiid.logging.LogConstants;
import org.teiid.logging.LogManager;
import org.teiid.runtime.NodeListener;
import org.teiid.runtime.RuntimePlugin;
import org.teiid.runtime.RuntimePlugin.Event;

public abstract class NodeTracker extends ReceiverAdapter{

public interface NodeListener {
void nodeJoined(String nodeName);
void nodeDropped(String nodeName);
}
public abstract ScheduledExecutorService getScheduledExecutorService();
private Map<Address, String> nodes = new HashMap<>();
private JChannel channel;
Expand Down
Expand Up @@ -24,7 +24,6 @@
import org.jboss.msc.service.StartException;
import org.jboss.msc.service.StopContext;
import org.jboss.msc.value.InjectedValue;
import org.teiid.runtime.NodeTracker;
import org.wildfly.clustering.jgroups.ChannelFactory;

class NodeTrackerService implements Service<NodeTracker> {
Expand Down
Expand Up @@ -111,7 +111,6 @@
import org.teiid.query.metadata.SystemMetadata;
import org.teiid.replication.jgroups.JGroupsObjectReplicator;
import org.teiid.runtime.MaterializationManager;
import org.teiid.runtime.NodeTracker;
import org.teiid.services.InternalEventDistributorFactory;
import org.teiid.services.SessionServiceImpl;
import org.teiid.translator.ExecutionFactory;
Expand Down
4 changes: 0 additions & 4 deletions runtime/pom.xml
Expand Up @@ -102,10 +102,6 @@
<groupId>org.jboss.marshalling</groupId>
<artifactId>jboss-marshalling</artifactId>
</dependency>
<dependency>
<groupId>org.jgroups</groupId>
<artifactId>jgroups</artifactId>
</dependency>
<dependency>
<groupId>org.jboss.logging</groupId>
<artifactId>jboss-logging</artifactId>
Expand Down
Expand Up @@ -53,7 +53,6 @@ public class EmbeddedConfiguration extends DQPConfiguration {
private CacheFactory cacheFactory;
private int maxResultSetCacheStaleness = DEFAULT_MAX_STALENESS_SECONDS;
private String infinispanConfigFile = "infinispan-config.xml"; //$NON-NLS-1$
private String jgroupsConfigFile; // from infinispan-core
private List<SocketConfiguration> transports;
private int maxODBCLobSizeAllowed = 5*1024*1024; // 5 MB
private int maxAsyncThreads = DEFAULT_MAX_ASYNC_WORKERS;
Expand Down Expand Up @@ -210,12 +209,6 @@ public int getMaxResultSetCacheStaleness() {
public void setMaxResultSetCacheStaleness(int maxResultSetCacheStaleness) {
this.maxResultSetCacheStaleness = maxResultSetCacheStaleness;
}
public String getJgroupsConfigFile() {
return jgroupsConfigFile;
}
public void setJgroupsConfigFile(String jgroupsConfigFile) {
this.jgroupsConfigFile = jgroupsConfigFile;
}

protected void stop() {
if (cacheManager != null) {
Expand Down
34 changes: 4 additions & 30 deletions runtime/src/main/java/org/teiid/runtime/EmbeddedServer.java
Expand Up @@ -121,7 +121,6 @@
import org.teiid.query.tempdata.GlobalTableStore;
import org.teiid.query.validator.ValidatorFailure;
import org.teiid.query.validator.ValidatorReport;
import org.teiid.replication.jgroups.JGroupsObjectReplicator;
import org.teiid.runtime.jmx.JMXService;
import org.teiid.services.AbstractEventDistributorFactoryService;
import org.teiid.services.BufferServiceImpl;
Expand Down Expand Up @@ -324,11 +323,9 @@ public ClassLoader getCallerClassloader() {
private SessionAwareCache<CachedResults> rs;
private SessionAwareCache<PreparedPlan> ppc;
protected ArrayList<SocketListener> transports = new ArrayList<SocketListener>();
private ScheduledExecutorService scheduler;
private MaterializationManager materializationMgr = null;
protected ScheduledExecutorService scheduler;
protected MaterializationManager materializationMgr = null;
private ShutDownListener shutdownListener = new ShutDownListener();
private SimpleChannelFactory channelFactory;
private NodeTracker nodeTracker = null;
private JMXService jmxService;

public EmbeddedServer() {
Expand Down Expand Up @@ -364,26 +361,9 @@ public synchronized void start(@SuppressWarnings("hiding") EmbeddedConfiguration
this.config = config;
System.setProperty("jboss.node.name", config.getNodeName()==null?"localhost":config.getNodeName());
this.cmr.setProvider(this);
this.eventDistributorFactoryService = new EmbeddedEventDistributorFactoryService();
this.eventDistributorFactoryService.start();
this.dqp.setEventDistributor(this.eventDistributorFactoryService.getReplicatedEventDistributor());
this.scheduler = Executors.newScheduledThreadPool(config.getMaxAsyncThreads(), new NamedThreadFactory("Asynch Worker")); //$NON-NLS-1$
this.replicator = config.getObjectReplicator();
if (this.replicator == null && config.getJgroupsConfigFile() != null) {
channelFactory = new SimpleChannelFactory(config);
this.replicator = new JGroupsObjectReplicator(channelFactory, this.scheduler);
try {
this.nodeTracker = new NodeTracker(channelFactory.createChannel("teiid-node-tracker"), config.getNodeName()) {
@Override
public ScheduledExecutorService getScheduledExecutorService() {
return scheduler;
}
};
} catch (Exception e) {
LogManager.logError(LogConstants.CTX_RUNTIME, e, RuntimePlugin.Util.gs(RuntimePlugin.Event.TEIID40089));
}
}
this.eventDistributorFactoryService = new EmbeddedEventDistributorFactoryService();
this.replicator = config.getObjectReplicator();
this.eventDistributorFactoryService = new EmbeddedEventDistributorFactoryService();
//must be called after the replicator is set
this.eventDistributorFactoryService.start();
this.dqp.setEventDistributor(this.eventDistributorFactoryService.getReplicatedEventDistributor());
Expand Down Expand Up @@ -441,9 +421,6 @@ public Object invoke(Object proxy, Method method, Object[] args)
this.materializationMgr = getMaterializationManager();
this.repo.addListener(this.materializationMgr);
this.repo.setAllowEnvFunction(this.config.isAllowEnvFunction());
if (this.nodeTracker != null) {
this.nodeTracker.addNodeListener(this.materializationMgr);
}
this.logon = new LogonImpl(sessionService, null);
services.registerClientService(ILogon.class, logon, LogConstants.CTX_SECURITY);
DQP dqpProxy = DQP.class.cast(Proxy.newProxyInstance(this.getClass().getClassLoader(), new Class[] {DQP.class}, new SessionCheckingProxy(dqp, LogConstants.CTX_DQP, MessageLevel.TRACE)));
Expand Down Expand Up @@ -924,9 +901,6 @@ public synchronized void stop() {
if (running == null || !running) {
return;
}
if (this.channelFactory != null) {
this.channelFactory.stop();
}
this.shutdownListener.setShutdownInProgress(true);
this.repo.removeListener(this.materializationMgr);
this.scheduler.shutdownNow();
Expand Down
Expand Up @@ -52,7 +52,6 @@
import org.teiid.query.metadata.MaterializationMetadataRepository;
import org.teiid.query.metadata.TransformationMetadata;
import org.teiid.query.tempdata.TempTableDataManager;
import org.teiid.runtime.NodeTracker.NodeListener;
import org.teiid.vdb.runtime.VDBKey;

public abstract class MaterializationManager implements VDBLifeCycleListener, NodeListener {
Expand Down
24 changes: 24 additions & 0 deletions runtime/src/main/java/org/teiid/runtime/NodeListener.java
@@ -0,0 +1,24 @@
/*
* Copyright Red Hat, Inc. and/or its affiliates
* and other contributors as indicated by the @author tags and
* the COPYRIGHT.txt file distributed with this work.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package org.teiid.runtime;

public interface NodeListener {
void nodeJoined(String nodeName);
void nodeDropped(String nodeName);
}
Expand Up @@ -25,6 +25,7 @@ <H2>Overview</H2>
<H2><A NAME="Highlights"></A>Highlights</H2>
<ul>
<li><a href="https://issues.jboss.org/browse/TEIID-5351">TEIID-5351</a> Updated to the WildFly 14.0.1 server.</li>
<li><a href="https://issues.jboss.org/browse/TEIID-5524">TEIID-5524</a> JMX support for Teiid standalone (Thorntail, Spring Boot, embedded)</li>
</ul>

<h2><a name="Compatibility">Compatibility Issues</a></h2>
Expand All @@ -40,9 +41,13 @@ <h2><a name="Compatibility">Compatibility Issues</a></h2>
<li><a href="https://issues.jboss.org/browse/TEIID-5511">TEIID-5511</a> The AdminShell kit has been removed. No further releases are planned.</li>
</ul>

<h4>from 11.2</h4>
<ul>
<li><a href="https://issues.jboss.org/browse/TEIID-5476">TEIID-5476</a> JGroups was removed as a direct dependency of the runtime and the associated property removed from the EmbeddedConfiguration. If you need clustering support with embedded, please raise an issue.</li>
</ul>

<h4>from 11.1</h4>
<ul>
<li><a href="https://issues.jboss.org/browse/TEIID-5497">TEIID-5497</a> MetadataRepository is again an interface. Custom concrete classes will need to be modified to implement, rather than extend.</li>
<li><a href="https://issues.jboss.org/browse/TEIID-5506">TEIID-5506</a> Removed the option to specify domain qualified logins.</li>
</ul>

Expand Down
Expand Up @@ -56,7 +56,6 @@
import org.teiid.metadata.VDBResource;
import org.teiid.metadata.index.VDBMetadataFactory;
import org.teiid.metadata.index.VDBMetadataFactory.IndexVDB;
import org.teiid.query.ObjectReplicator;
import org.teiid.query.metadata.VDBResources.Resource;
import org.teiid.query.optimizer.capabilities.BasicSourceCapabilities;
import org.teiid.query.optimizer.capabilities.SourceCapabilities;
Expand Down Expand Up @@ -271,12 +270,4 @@ public SessionServiceImpl getSessionService() {
return this.sessionService;
}

public void setObjectReplicator(ObjectReplicator replicator) {
this.replicator = replicator;
}

public ObjectReplicator getObjectReplicator() {
return this.replicator;
}

}
@@ -0,0 +1,93 @@
/*
* Copyright Red Hat, Inc. and/or its affiliates
* and other contributors as indicated by the @author tags and
* the COPYRIGHT.txt file distributed with this work.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package org.teiid.runtime;

import java.util.concurrent.ScheduledExecutorService;

import org.infinispan.transaction.tm.DummyTransactionManager;
import org.teiid.jboss.NodeTracker;
import org.teiid.jdbc.FakeServer;
import org.teiid.logging.LogConstants;
import org.teiid.logging.LogManager;
import org.teiid.query.ObjectReplicator;
import org.teiid.replication.jgroups.JGroupsObjectReplicator;

@SuppressWarnings("nls")
public class ReplicatedServer extends FakeServer {

private SimpleChannelFactory channelFactory;
private NodeTracker nodeTracker;

static {
System.setProperty("jgroups.bind_addr", "127.0.0.1");
}

public ReplicatedServer(boolean start) {
super(start);
}

public static ReplicatedServer createServer(String nodeName, String ispn, String jgroups) throws Exception {
ReplicatedServer server = new ReplicatedServer(false);
server.channelFactory = new SimpleChannelFactory(jgroups);

EmbeddedConfiguration config = new EmbeddedConfiguration() {
@Override
public ObjectReplicator getObjectReplicator() {
return new JGroupsObjectReplicator(server.channelFactory, server.scheduler);
}
};
config.setInfinispanConfigFile(ispn);
config.setTransactionManager(new DummyTransactionManager());
config.setNodeName(nodeName);
server.start(config, true);

return server;
}

@Override
public synchronized void start(EmbeddedConfiguration config) {
super.start(config);
try {
this.nodeTracker = new NodeTracker(channelFactory.createChannel("teiid-node-tracker"), config.getNodeName()) {
@Override
public ScheduledExecutorService getScheduledExecutorService() {
return scheduler;
}
};
this.nodeTracker.addNodeListener(this.materializationMgr);
} catch (Exception e) {
LogManager.logError(LogConstants.CTX_RUNTIME, e, RuntimePlugin.Util.gs(RuntimePlugin.Event.TEIID40089));
}
}

@Override
public synchronized void stop() {
super.stop();
this.channelFactory.stop();
}

public void setObjectReplicator(ObjectReplicator replicator) {
this.replicator = replicator;
}

public ObjectReplicator getObjectReplicator() {
return this.replicator;
}

}
Expand Up @@ -23,21 +23,21 @@
import org.teiid.replication.jgroups.ChannelFactory;

final class SimpleChannelFactory implements ChannelFactory {
private final EmbeddedConfiguration embeddedConfiguration;
private final String jgroupsConfigFile;
private JChannel channel;

/**
* @param embeddedConfiguration
*/
SimpleChannelFactory(EmbeddedConfiguration embeddedConfiguration) {
this.embeddedConfiguration = embeddedConfiguration;
SimpleChannelFactory(String jgroupsConfigFile) {
this.jgroupsConfigFile = jgroupsConfigFile;
}

@Override
public JChannel createChannel(String id) throws Exception {
synchronized (this) {
if (channel == null) {
channel = new JChannel(this.getClass().getClassLoader().getResource(this.embeddedConfiguration.getJgroupsConfigFile()));
channel = new JChannel(this.getClass().getClassLoader().getResource(jgroupsConfigFile));
channel.connect("teiid-replicator"); //$NON-NLS-1$
}
}
Expand Down

0 comments on commit 8777022

Please sign in to comment.