Skip to content

Commit

Permalink
save work #7529
Browse files Browse the repository at this point in the history
  • Loading branch information
rymsha committed Oct 15, 2019
1 parent 4ecf6a1 commit 54f2f61
Show file tree
Hide file tree
Showing 9 changed files with 26 additions and 90 deletions.
2 changes: 1 addition & 1 deletion buildSrc/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ repositories {
}

dependencies {
compile 'biz.aQute.bnd:biz.aQute.bnd.gradle:4.2.0'
runtimeOnly 'biz.aQute.bnd:biz.aQute.bnd.gradle:4.3.0'
compile 'com.moowork.gradle:gradle-node-plugin:1.0.1'
compile 'org.eclipse.jgit:org.eclipse.jgit:3.7.0.201502260915-r'
compile 'com.gradle.publish:plugin-publish-plugin:0.9.3'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,7 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.enonic.xp.cluster.Cluster;
import com.enonic.xp.cluster.ClusterConfig;
import com.enonic.xp.cluster.ClusterHealth;
import com.enonic.xp.cluster.ClusterId;
import com.enonic.xp.cluster.ClusterNode;
import com.enonic.xp.cluster.ClusterNodes;
import com.enonic.xp.ignite.impl.config.ConfigurationFactory;
Expand All @@ -31,7 +28,6 @@

@Component(immediate = true, configurationPid = "com.enonic.xp.ignite")
public class IgniteCluster
implements Cluster
{
private Ignite ignite;

Expand Down Expand Up @@ -62,9 +58,19 @@ public void activate( final BundleContext context, final IgniteSettings igniteSe
execute();

System.setProperty( IGNITE_NO_SHUTDOWN_HOOK, "true" );
this.ignite = Ignition.start( igniteConfig );

// Register admin-client to use in e.g reporting
final Thread thread = Thread.currentThread();
ClassLoader classLoader = thread.getContextClassLoader();
try
{
thread.setContextClassLoader( Ignite.class.getClassLoader() );
this.ignite = Ignition.start( igniteConfig );
}
finally
{
thread.setContextClassLoader( classLoader );
}
context.registerService( Ignite.class, ignite, new Hashtable<>() );
context.registerService( IgniteAdminClient.class, new IgniteAdminClientImpl( this.ignite ), new Hashtable<>() );
}

Expand All @@ -81,33 +87,8 @@ private void adjustLoggingVerbosity()
public void deactivate()
{
this.ignite.close();
unregisterClient();
}

@Override
public ClusterId getId()
{
return ClusterId.from( "ignite" );
}

@Override
public ClusterHealth getHealth()
{
return ClusterHealth.green();
}

@Override
public ClusterNodes getNodes()
{
try
{
return doGetNodes();
}
catch ( java.lang.IllegalStateException e )
{
return ClusterNodes.create().build();
}
}

private ClusterNodes doGetNodes()
{
Expand All @@ -123,53 +104,6 @@ private ClusterNodes doGetNodes()
return builder.build();
}

@Override
public void enable()
{
registerService();
}

@Override
public void disable()
{
unregisterClient();
}

@Override
public boolean isEnabled()
{
return this.reg != null;
}

private void registerService()
{
if ( this.reg != null )
{
return;
}

LOG.info( "Cluster operational, register " + this.getId() );

this.reg = context.registerService( Ignite.class, ignite, new Hashtable<>() );
}

private void unregisterClient()
{
if ( this.reg == null )
{
return;
}

try
{
LOG.info( "Cluster not operational, unregister " + this.getId() );
this.reg.unregister();
}
finally
{
this.reg = null;
}
}

@SuppressWarnings("unused")
@Reference
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,8 @@ public IgniteConfiguration execute()

private AddressResolver getAddressResolver()
{
final String discoveryTcpLocalAddress = clusterConfig.networkHost();
final String publishAddress = clusterConfig.networkPublishHost();
final String discoveryTcpLocalAddress = igniteSettings.network_host();
final String publishAddress = igniteSettings.network_publish_host();
if ( isEmpty( publishAddress ) || isEmpty( discoveryTcpLocalAddress ) )
{
return null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,8 @@
int communication_message_queue_limit() default 1024;

String discovery_unicast_sockets();

String network_publish_host();

String network_host();
}
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ TcpDiscoveryVmIpFinder execute()

final String portPrefix = getPortPrefix();

final String discoveryTcpLocalAddress = clusterConfig.networkHost();
final String discoveryTcpLocalAddress = igniteConfig.network_host();
final Stream<String> configLocalAddress = Stream.of( discoveryTcpLocalAddress + portPrefix );
final Stream<String> discoveryAddresses = getDiscoveryAddresses( portPrefix );
final List<String> hostStrings = Stream.concat( discoveryAddresses, configLocalAddress ).
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ TcpDiscoverySpi execute()
discoverySpi.setIpFinder( createStaticIpConfig() ).
setLocalPort( igniteConfig.discovery_tcp_port() ).
setLocalPortRange( igniteConfig.discovery_tcp_port_range() ).
setLocalAddress( clusterConfig.networkHost() ).
setLocalAddress( igniteConfig.network_host() ).
setReconnectCount( igniteConfig.discovery_tcp_reconnect() ).
setAckTimeout( igniteConfig.discovery_tcp_ack_timeout() ).
setJoinTimeout( igniteConfig.discovery_tcp_join_timeout() ).
Expand Down
7 changes: 3 additions & 4 deletions modules/runtime/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,8 @@ addBundle( project( ':repack:repack-resteasy' ), 8 )
addBundle( project( ':repack:repack-attoparser' ), 8 )
addBundle( project( ':repack:repack-okhttp' ), 8 )
addBundle( 'javax.cache:cache-api:1.1.1' , 8 )
addBundle( 'org.apache.ignite:ignite-core:2.3.0', 8 )
addBundle( 'org.apache.ignite:ignite-osgi:2.3.0', 8 )
addBundle( 'org.apache.ignite:ignite-web:2.3.0', 8 )
addBundle( 'org.apache.ignite:ignite-core:2.7.6', 8 )
addBundle( 'org.apache.ignite:ignite-osgi:2.7.6', 8 )

// API bundles
addBundle( project( ':core:core-api' ), 10 )
Expand All @@ -87,7 +86,7 @@ addBundle( project( ':core:core-image' ), 22 )
addBundle( project( ':core:core-export' ), 22 )
addBundle( project( ':core:core-mail' ), 22 )
addBundle( project( ':core:core-elasticsearch' ), 22 )
//addBundle( project( ':core:core-ignite' ), 22 )
addBundle( project( ':core:core-ignite' ), 22 )
addBundle( project( ':core:core-content' ), 22 )
addBundle( project( ':core:core-site' ), 22 )
addBundle( project( ':core:core-i18n' ), 22 )
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public void activate( final BundleContext context, final JettyConfig config )
this.service = new JettyService();
this.service.config = this.config;
this.service.workerName = clusterConfig.name().toString();
if ( clusterConfig.isEnabled() && clusterConfig.isSessionReplicationEnabled() )
if ( clusterConfig.isSessionReplicationEnabled() )
{
this.service.sessionDataStore = sessionDataStore;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
import org.osgi.service.component.annotations.Activate;
import org.osgi.service.component.annotations.Component;
import org.osgi.service.component.annotations.Reference;
import org.osgi.service.component.annotations.ReferenceCardinality;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

Expand Down Expand Up @@ -41,7 +40,7 @@ public void activate( final WebSessionConfig config )
igniteCache = ignite.getOrCreateCache( SessionCacheConfigFactory.create( WEB_SESSION_CACHE, config ) );
}

@Reference(cardinality = ReferenceCardinality.OPTIONAL)
@Reference
public void setIgnite( final Ignite ignite )
{
this.ignite = ignite;
Expand Down

0 comments on commit 54f2f61

Please sign in to comment.