IDEMPIERE-491 Caching data can generate problem. Improve startup of hazelcast service. Added fragment to allow modification of hazelcast service configuration.
This commit is contained in:
parent
7dea196887
commit
a7d41c111c
File diff suppressed because one or more lines are too long
|
@ -21,8 +21,8 @@
|
|||
<stringAttribute key="pde.version" value="3.3"/>
|
||||
<stringAttribute key="product" value="org.adempiere.ui.swing.client_product"/>
|
||||
<stringAttribute key="productFile" value="/org.adempiere.ui.swing-feature/swingclient.product"/>
|
||||
<stringAttribute key="selected_target_plugins" value="com.springsource.javax.ejb@default:default,com.springsource.javax.jms@default:default,com.springsource.javax.mail*1.4.0@default:default,com.springsource.javax.mail*1.4.5@default:default,com.springsource.javax.management.j2ee@default:default,com.springsource.javax.persistence@default:default,com.springsource.javax.transaction@default:default,com.springsource.javax.xml.rpc@default:default,com.springsource.javax.xml.soap@default:default,com.springsource.net.sf.cglib@default:default,com.springsource.org.aopalliance@default:default,com.springsource.org.apache.activemq@default:default,com.springsource.org.apache.commons.logging@default:default,com.springsource.org.apache.kahadb@default:default,com.springsource.org.apache.xmlcommons@default:default,com.springsource.slf4j.api@default:default,com.springsource.slf4j.jcl@default:false,com.springsource.slf4j.nop@default:default,javax.el@default:default,javax.servlet@default:default,javax.xml@default:default,org.apache.ant@default:default,org.apache.commons.codec@default:default,org.apache.commons.collections@default:default,org.apache.commons.httpclient@default:default,org.apache.commons.logging@default:default,org.apache.commons.net@default:default,org.apache.poi@default:default,org.apache.xerces@default:default,org.apache.xml.resolver@default:default,org.apache.xml.serializer@default:default,org.eclipse.ant.core@default:default,org.eclipse.core.contenttype@default:default,org.eclipse.core.jobs@default:default,org.eclipse.core.net@default:default,org.eclipse.core.runtime.compatibility.auth@default:default,org.eclipse.core.runtime@default:true,org.eclipse.core.variables@default:default,org.eclipse.ecf.filetransfer@default:default,org.eclipse.ecf.identity@default:default,org.eclipse.ecf.provider.filetransfer.httpclient.ssl@default:false,org.eclipse.ecf.provider.filetransfer.httpclient@default:default,org.eclipse.ecf.provider.filetransfer.ssl@default:false,org.eclipse.ecf.provider.filetransfer@default:default,org.eclipse.ecf.ssl@default:false,org.eclipse.ecf@default:default,org.eclipse.equinox.app@default:default,org.eclipse.equinox.common@2:true,org.eclipse.equinox.ds@3:true,org.eclipse.equinox.event@3:true,org.eclipse.equinox.frameworkadmin.equinox@default:default,org.eclipse.equinox.frameworkadmin@default:default,org.eclipse.equinox.http.registry@default:default,org.eclipse.equinox.launcher.gtk.linux.x86_64@default:false,org.eclipse.equinox.launcher@default:default,org.eclipse.equinox.p2.artifact.repository@default:default,org.eclipse.equinox.p2.console@default:default,org.eclipse.equinox.p2.core@default:default,org.eclipse.equinox.p2.director@default:default,org.eclipse.equinox.p2.engine@default:default,org.eclipse.equinox.p2.garbagecollector@default:default,org.eclipse.equinox.p2.jarprocessor@default:default,org.eclipse.equinox.p2.metadata.repository@default:default,org.eclipse.equinox.p2.metadata@default:default,org.eclipse.equinox.p2.publisher@default:default,org.eclipse.equinox.p2.ql@default:default,org.eclipse.equinox.p2.repository@default:default,org.eclipse.equinox.p2.touchpoint.eclipse@default:default,org.eclipse.equinox.p2.touchpoint.natives@default:default,org.eclipse.equinox.preferences@default:default,org.eclipse.equinox.registry@default:default,org.eclipse.equinox.security@default:default,org.eclipse.equinox.simpleconfigurator.manipulator@default:default,org.eclipse.equinox.simpleconfigurator@1:true,org.eclipse.equinox.util@default:default,org.eclipse.osgi.services@3:true,org.eclipse.osgi@-1:true,org.hamcrest.core@default:default,org.junit@default:default,org.restlet.ext.net@default:true,org.restlet@default:true,org.sat4j.core@default:default,org.sat4j.pb@default:default,org.springframework.aop@default:default,org.springframework.beans@default:default,org.springframework.context@default:default,org.springframework.core@default:default"/>
|
||||
<stringAttribute key="selected_workspace_plugins" value="org.adempiere.base.callout@default:default,org.adempiere.base.process@default:default,org.adempiere.base@4:true,org.adempiere.extend@default:false,org.adempiere.install@default:default,org.adempiere.payment.processor@default:default,org.adempiere.pipo.handlers@default:default,org.adempiere.pipo@default:default,org.adempiere.plugin.utils@default:default,org.adempiere.replication@default:default,org.adempiere.report.jasper.font.demo@default:default,org.adempiere.report.jasper.library@default:default,org.adempiere.report.jasper.swing@default:default,org.adempiere.report.jasper@default:default,org.adempiere.ui.swing@default:default,org.adempiere.ui@default:default,org.apache.ecs@default:default,org.compiere.db.oracle.provider@default:default,org.compiere.db.postgresql.provider@default:default,org.idempiere.hazelcast.service@default:true"/>
|
||||
<stringAttribute key="selected_target_plugins" value="com.springsource.javax.ejb@default:default,com.springsource.javax.jms@default:default,com.springsource.javax.mail@default:default,com.springsource.javax.management.j2ee@default:default,com.springsource.javax.persistence@default:default,com.springsource.javax.transaction@default:default,com.springsource.javax.xml.rpc@default:default,com.springsource.javax.xml.soap@default:default,com.springsource.net.sf.cglib@default:default,com.springsource.org.aopalliance@default:default,com.springsource.org.apache.activemq@default:default,com.springsource.org.apache.commons.logging@default:default,com.springsource.org.apache.kahadb@default:default,com.springsource.org.apache.xmlcommons@default:default,com.springsource.slf4j.api@default:default,com.springsource.slf4j.jcl@default:false,com.springsource.slf4j.nop@default:false,javax.el@default:default,javax.servlet@default:default,javax.xml@default:default,org.apache.ant@default:default,org.apache.commons.codec@default:default,org.apache.commons.collections@default:default,org.apache.commons.httpclient@default:default,org.apache.commons.logging@default:default,org.apache.commons.net@default:default,org.apache.poi@default:default,org.apache.xerces@default:default,org.apache.xml.resolver@default:default,org.apache.xml.serializer@default:default,org.eclipse.ant.core@default:default,org.eclipse.core.contenttype@default:default,org.eclipse.core.jobs@default:default,org.eclipse.core.net@default:default,org.eclipse.core.runtime.compatibility.auth@default:default,org.eclipse.core.runtime@default:true,org.eclipse.core.variables@default:default,org.eclipse.ecf.filetransfer@default:default,org.eclipse.ecf.identity@default:default,org.eclipse.ecf.provider.filetransfer.httpclient.ssl@default:false,org.eclipse.ecf.provider.filetransfer.httpclient@default:default,org.eclipse.ecf.provider.filetransfer.ssl@default:false,org.eclipse.ecf.provider.filetransfer@default:default,org.eclipse.ecf.ssl@default:false,org.eclipse.ecf@default:default,org.eclipse.equinox.app@default:default,org.eclipse.equinox.common@2:true,org.eclipse.equinox.ds@3:true,org.eclipse.equinox.event@3:true,org.eclipse.equinox.frameworkadmin.equinox@default:default,org.eclipse.equinox.frameworkadmin@default:default,org.eclipse.equinox.http.registry@default:default,org.eclipse.equinox.launcher.gtk.linux.x86_64@default:false,org.eclipse.equinox.launcher@default:default,org.eclipse.equinox.p2.artifact.repository@default:default,org.eclipse.equinox.p2.console@default:default,org.eclipse.equinox.p2.core@default:default,org.eclipse.equinox.p2.director@default:default,org.eclipse.equinox.p2.engine@default:default,org.eclipse.equinox.p2.garbagecollector@default:default,org.eclipse.equinox.p2.jarprocessor@default:default,org.eclipse.equinox.p2.metadata.repository@default:default,org.eclipse.equinox.p2.metadata@default:default,org.eclipse.equinox.p2.publisher@default:default,org.eclipse.equinox.p2.ql@default:default,org.eclipse.equinox.p2.repository@default:default,org.eclipse.equinox.p2.touchpoint.eclipse@default:default,org.eclipse.equinox.p2.touchpoint.natives@default:default,org.eclipse.equinox.preferences@default:default,org.eclipse.equinox.registry@default:default,org.eclipse.equinox.security@default:default,org.eclipse.equinox.simpleconfigurator.manipulator@default:default,org.eclipse.equinox.simpleconfigurator@1:true,org.eclipse.equinox.util@default:default,org.eclipse.osgi.services@3:true,org.eclipse.osgi@-1:true,org.hamcrest.core@default:default,org.junit@default:default,org.restlet.ext.net@default:true,org.restlet@default:true,org.sat4j.core@default:default,org.sat4j.pb@default:default,org.springframework.aop@default:default,org.springframework.beans@default:default,org.springframework.context@default:default,org.springframework.core@default:default"/>
|
||||
<stringAttribute key="selected_workspace_plugins" value="org.adempiere.base.callout@default:default,org.adempiere.base.process@default:default,org.adempiere.base@4:true,org.adempiere.extend@default:false,org.adempiere.install@default:default,org.adempiere.payment.processor@default:default,org.adempiere.pipo.handlers@default:default,org.adempiere.pipo@default:default,org.adempiere.plugin.utils@default:default,org.adempiere.replication@default:default,org.adempiere.report.jasper.library@default:default,org.adempiere.report.jasper.swing@default:default,org.adempiere.report.jasper@default:default,org.adempiere.ui.swing@default:default,org.adempiere.ui@default:default,org.apache.ecs@default:default,org.compiere.db.oracle.provider@default:default,org.compiere.db.postgresql.provider@default:default,org.idempiere.hazelcast.service.config@default:default,org.idempiere.hazelcast.service@default:true"/>
|
||||
<booleanAttribute key="show_selected_only" value="false"/>
|
||||
<booleanAttribute key="tracing" value="false"/>
|
||||
<booleanAttribute key="useCustomFeatures" value="false"/>
|
||||
|
|
|
@ -38,4 +38,11 @@
|
|||
fragment="true"
|
||||
unpack="false"/>
|
||||
|
||||
<plugin
|
||||
id="org.idempiere.hazelcast.service.config"
|
||||
download-size="0"
|
||||
install-size="0"
|
||||
version="0.0.0"
|
||||
fragment="true"/>
|
||||
|
||||
</feature>
|
||||
|
|
|
@ -0,0 +1,7 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<classpath>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
|
||||
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
|
||||
<classpathentry kind="src" path="src"/>
|
||||
<classpathentry kind="output" path="bin"/>
|
||||
</classpath>
|
|
@ -0,0 +1,28 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<projectDescription>
|
||||
<name>org.idempiere.hazelcast.service.config</name>
|
||||
<comment></comment>
|
||||
<projects>
|
||||
</projects>
|
||||
<buildSpec>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.jdt.core.javabuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.pde.ManifestBuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.pde.SchemaBuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
</buildSpec>
|
||||
<natures>
|
||||
<nature>org.eclipse.pde.PluginNature</nature>
|
||||
<nature>org.eclipse.jdt.core.javanature</nature>
|
||||
</natures>
|
||||
</projectDescription>
|
|
@ -0,0 +1,7 @@
|
|||
eclipse.preferences.version=1
|
||||
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
|
||||
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
|
||||
org.eclipse.jdt.core.compiler.compliance=1.6
|
||||
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
|
||||
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
|
||||
org.eclipse.jdt.core.compiler.source=1.6
|
|
@ -0,0 +1,3 @@
|
|||
eclipse.preferences.version=1
|
||||
pluginProject.extensions=false
|
||||
resolve.requirebundle=false
|
|
@ -0,0 +1,7 @@
|
|||
Manifest-Version: 1.0
|
||||
Bundle-ManifestVersion: 2
|
||||
Bundle-Name: Hazelcast Service Configuration
|
||||
Bundle-SymbolicName: org.idempiere.hazelcast.service.config
|
||||
Bundle-Version: 1.0.0.qualifier
|
||||
Fragment-Host: org.idempiere.hazelcast.service;bundle-version="1.0.0"
|
||||
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
|
|
@ -0,0 +1,4 @@
|
|||
source.. = src/
|
||||
output.. = bin/
|
||||
bin.includes = META-INF/,\
|
||||
.
|
|
@ -0,0 +1,196 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!--
|
||||
~ Copyright (c) 2008-2012, Hazel Bilisim Ltd. All Rights Reserved.
|
||||
~
|
||||
~ 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.
|
||||
-->
|
||||
|
||||
<hazelcast xsi:schemaLocation="http://www.hazelcast.com/schema/config hazelcast-config-2.4.xsd"
|
||||
xmlns="http://www.hazelcast.com/schema/config"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
|
||||
<group>
|
||||
<name>dev</name>
|
||||
<password>dev-pass</password>
|
||||
</group>
|
||||
<management-center enabled="false">http://localhost:8080/mancenter</management-center>
|
||||
<network>
|
||||
<port auto-increment="true">5701</port>
|
||||
<outbound-ports>
|
||||
<!--
|
||||
Allowed port range when connecting to other nodes.
|
||||
0 or * means use system provided port.
|
||||
-->
|
||||
<ports>0</ports>
|
||||
</outbound-ports>
|
||||
<join>
|
||||
<multicast enabled="true">
|
||||
<multicast-group>224.2.2.3</multicast-group>
|
||||
<multicast-port>54327</multicast-port>
|
||||
</multicast>
|
||||
<tcp-ip enabled="false">
|
||||
<interface>127.0.0.1</interface>
|
||||
</tcp-ip>
|
||||
<aws enabled="false">
|
||||
<access-key>my-access-key</access-key>
|
||||
<secret-key>my-secret-key</secret-key>
|
||||
<!--optional, default is us-east-1 -->
|
||||
<region>us-west-1</region>
|
||||
<!--optional, default is ec2.amazonaws.com. If set, region shouldn't be set as it will override this property -->
|
||||
<hostHeader>ec2.amazonaws.com</hostHeader>
|
||||
<!-- optional, only instances belonging to this group will be discovered, default will try all running instances -->
|
||||
<security-group-name>hazelcast-sg</security-group-name>
|
||||
<tag-key>type</tag-key>
|
||||
<tag-value>hz-nodes</tag-value>
|
||||
</aws>
|
||||
</join>
|
||||
<interfaces enabled="false">
|
||||
<interface>10.10.1.*</interface>
|
||||
</interfaces>
|
||||
<ssl enabled="false" />
|
||||
<socket-interceptor enabled="false" />
|
||||
<symmetric-encryption enabled="false">
|
||||
<!--
|
||||
encryption algorithm such as
|
||||
DES/ECB/PKCS5Padding,
|
||||
PBEWithMD5AndDES,
|
||||
AES/CBC/PKCS5Padding,
|
||||
Blowfish,
|
||||
DESede
|
||||
-->
|
||||
<algorithm>PBEWithMD5AndDES</algorithm>
|
||||
<!-- salt value to use when generating the secret key -->
|
||||
<salt>thesalt</salt>
|
||||
<!-- pass phrase to use when generating the secret key -->
|
||||
<password>thepass</password>
|
||||
<!-- iteration count to use when generating the secret key -->
|
||||
<iteration-count>19</iteration-count>
|
||||
</symmetric-encryption>
|
||||
<asymmetric-encryption enabled="false">
|
||||
<!-- encryption algorithm -->
|
||||
<algorithm>RSA/NONE/PKCS1PADDING</algorithm>
|
||||
<!-- private key password -->
|
||||
<keyPassword>thekeypass</keyPassword>
|
||||
<!-- private key alias -->
|
||||
<keyAlias>local</keyAlias>
|
||||
<!-- key store type -->
|
||||
<storeType>JKS</storeType>
|
||||
<!-- key store password -->
|
||||
<storePassword>thestorepass</storePassword>
|
||||
<!-- path to the key store -->
|
||||
<storePath>keystore</storePath>
|
||||
</asymmetric-encryption>
|
||||
</network>
|
||||
<partition-group enabled="false"/>
|
||||
<executor-service>
|
||||
<core-pool-size>16</core-pool-size>
|
||||
<max-pool-size>64</max-pool-size>
|
||||
<keep-alive-seconds>60</keep-alive-seconds>
|
||||
</executor-service>
|
||||
<queue name="default">
|
||||
<!--
|
||||
Maximum size of the queue. When a JVM's local queue size reaches the maximum,
|
||||
all put/offer operations will get blocked until the queue size
|
||||
of the JVM goes down below the maximum.
|
||||
Any integer between 0 and Integer.MAX_VALUE. 0 means
|
||||
Integer.MAX_VALUE. Default is 0.
|
||||
-->
|
||||
<max-size-per-jvm>0</max-size-per-jvm>
|
||||
<!--
|
||||
Name of the map configuration that will be used for the backing distributed
|
||||
map for this queue.
|
||||
-->
|
||||
<backing-map-ref>default</backing-map-ref>
|
||||
</queue>
|
||||
<map name="default">
|
||||
<!--
|
||||
Number of backups. If 1 is set as the backup-count for example,
|
||||
then all entries of the map will be copied to another JVM for
|
||||
fail-safety. 0 means no backup.
|
||||
-->
|
||||
<backup-count>1</backup-count>
|
||||
<!--
|
||||
Number of async backups. 0 means no backup.
|
||||
-->
|
||||
<async-backup-count>0</async-backup-count>
|
||||
<!--
|
||||
Maximum number of seconds for each entry to stay in the map. Entries that are
|
||||
older than <time-to-live-seconds> and not updated for <time-to-live-seconds>
|
||||
will get automatically evicted from the map.
|
||||
Any integer between 0 and Integer.MAX_VALUE. 0 means infinite. Default is 0.
|
||||
-->
|
||||
<time-to-live-seconds>0</time-to-live-seconds>
|
||||
<!--
|
||||
Maximum number of seconds for each entry to stay idle in the map. Entries that are
|
||||
idle(not touched) for more than <max-idle-seconds> will get
|
||||
automatically evicted from the map. Entry is touched if get, put or containsKey is called.
|
||||
Any integer between 0 and Integer.MAX_VALUE. 0 means infinite. Default is 0.
|
||||
-->
|
||||
<max-idle-seconds>0</max-idle-seconds>
|
||||
<!--
|
||||
Valid values are:
|
||||
NONE (no eviction),
|
||||
LRU (Least Recently Used),
|
||||
LFU (Least Frequently Used).
|
||||
NONE is the default.
|
||||
-->
|
||||
<eviction-policy>NONE</eviction-policy>
|
||||
<!--
|
||||
Maximum size of the map. When max size is reached,
|
||||
map is evicted based on the policy defined.
|
||||
Any integer between 0 and Integer.MAX_VALUE. 0 means
|
||||
Integer.MAX_VALUE. Default is 0.
|
||||
-->
|
||||
<max-size policy="cluster_wide_map_size">0</max-size>
|
||||
<!--
|
||||
When max. size is reached, specified percentage of
|
||||
the map will be evicted. Any integer between 0 and 100.
|
||||
If 25 is set for example, 25% of the entries will
|
||||
get evicted.
|
||||
-->
|
||||
<eviction-percentage>25</eviction-percentage>
|
||||
<!--
|
||||
While recovering from split-brain (network partitioning),
|
||||
map entries in the small cluster will merge into the bigger cluster
|
||||
based on the policy set here. When an entry merge into the
|
||||
cluster, there might an existing entry with the same key already.
|
||||
Values of these entries might be different for that same key.
|
||||
Which value should be set for the key? Conflict is resolved by
|
||||
the policy set here. Default policy is hz.ADD_NEW_ENTRY
|
||||
|
||||
There are built-in merge policies such as
|
||||
hz.NO_MERGE ; no entry will merge.
|
||||
hz.ADD_NEW_ENTRY ; entry will be added if the merging entry's key
|
||||
doesn't exist in the cluster.
|
||||
hz.HIGHER_HITS ; entry with the higher hits wins.
|
||||
hz.LATEST_UPDATE ; entry with the latest update wins.
|
||||
-->
|
||||
<merge-policy>hz.ADD_NEW_ENTRY</merge-policy>
|
||||
</map>
|
||||
<!-- Add your own semaphore configurations here:
|
||||
<semaphore name="default">
|
||||
<initial-permits>10</initial-permits>
|
||||
<semaphore-factory enabled="true">
|
||||
<class-name>com.acme.MySemaphoreFactory</class-name>
|
||||
</semaphore-factory>
|
||||
</semaphore>
|
||||
-->
|
||||
|
||||
<!-- Add your own map merge policy implementations here:
|
||||
<merge-policies>
|
||||
<map-merge-policy name="MY_MERGE_POLICY">
|
||||
<class-name>com.acme.MyOwnMergePolicy</class-name>
|
||||
</map-merge-policy>
|
||||
</merge-policies>
|
||||
-->
|
||||
|
||||
</hazelcast>
|
|
@ -13,8 +13,10 @@
|
|||
*****************************************************************************/
|
||||
package org.idempiere.hazelcast.service;
|
||||
|
||||
import java.util.concurrent.ExecutionException;
|
||||
import java.util.concurrent.Future;
|
||||
import java.util.concurrent.ScheduledThreadPoolExecutor;
|
||||
import java.util.concurrent.atomic.AtomicReference;
|
||||
|
||||
import org.compiere.Adempiere;
|
||||
import org.compiere.model.ServerStateChangeEvent;
|
||||
|
@ -22,7 +24,6 @@ import org.compiere.model.ServerStateChangeListener;
|
|||
import org.osgi.framework.BundleActivator;
|
||||
import org.osgi.framework.BundleContext;
|
||||
|
||||
import com.hazelcast.config.*;
|
||||
import com.hazelcast.core.*;
|
||||
|
||||
/**
|
||||
|
@ -38,8 +39,8 @@ public class Activator implements BundleActivator {
|
|||
return context;
|
||||
}
|
||||
|
||||
protected static HazelcastInstance hazelcastInstance;
|
||||
private Future<?> future;
|
||||
private static HazelcastInstance hazelcastInstance;
|
||||
private static AtomicReference<Future<?>> futureRef = new AtomicReference<Future<?>>();
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
|
@ -52,7 +53,6 @@ public class Activator implements BundleActivator {
|
|||
createHazelCastInstance();
|
||||
else {
|
||||
Adempiere.addServerStateChangeListener(new ServerStateChangeListener() {
|
||||
|
||||
@Override
|
||||
public void stateChange(ServerStateChangeEvent event) {
|
||||
if (event.getEventType() == ServerStateChangeEvent.SERVER_START)
|
||||
|
@ -64,13 +64,27 @@ public class Activator implements BundleActivator {
|
|||
|
||||
private void createHazelCastInstance() {
|
||||
ScheduledThreadPoolExecutor executor = Adempiere.getThreadPoolExecutor();
|
||||
future = executor.submit(new Runnable() {
|
||||
|
||||
Future<?> future = executor.submit(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
Config config = new Config();
|
||||
hazelcastInstance = Hazelcast.newHazelcastInstance(config);
|
||||
hazelcastInstance = Hazelcast.newHazelcastInstance(null);
|
||||
}
|
||||
});
|
||||
futureRef.set(future);
|
||||
}
|
||||
|
||||
public static HazelcastInstance getHazelcastInstance() {
|
||||
Future<?> future = futureRef.get();
|
||||
if (future != null && !future.isDone()) {
|
||||
try {
|
||||
future.get();
|
||||
} catch (InterruptedException e) {
|
||||
} catch (ExecutionException e) {
|
||||
}
|
||||
}
|
||||
|
||||
return hazelcastInstance;
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -79,11 +93,13 @@ public class Activator implements BundleActivator {
|
|||
*/
|
||||
public void stop(BundleContext bundleContext) throws Exception {
|
||||
Activator.context = null;
|
||||
Future<?> future = futureRef.get();
|
||||
if (future != null && !future.isDone()) {
|
||||
future.cancel(true);
|
||||
} else if (hazelcastInstance != null) {
|
||||
hazelcastInstance.getLifecycleService().shutdown();
|
||||
hazelcastInstance = null;
|
||||
}
|
||||
futureRef.set(null);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -36,24 +36,24 @@ public class CacheServiceImpl implements ICacheService {
|
|||
*/
|
||||
@Override
|
||||
public <K, V> Map<K, V> getMap(String name) {
|
||||
if (Activator.hazelcastInstance != null)
|
||||
return Activator.hazelcastInstance.getMap(name);
|
||||
if (Activator.getHazelcastInstance() != null)
|
||||
return Activator.getHazelcastInstance().getMap(name);
|
||||
else
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public <K> List<K> getList(String name) {
|
||||
if (Activator.hazelcastInstance != null)
|
||||
return Activator.hazelcastInstance.getList(name);
|
||||
if (Activator.getHazelcastInstance() != null)
|
||||
return Activator.getHazelcastInstance().getList(name);
|
||||
else
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public <K> Set<K> getSet(String name) {
|
||||
if (Activator.hazelcastInstance != null)
|
||||
return Activator.hazelcastInstance.getSet(name);
|
||||
if (Activator.getHazelcastInstance() != null)
|
||||
return Activator.getHazelcastInstance().getSet(name);
|
||||
else
|
||||
return null;
|
||||
}
|
||||
|
|
|
@ -37,7 +37,7 @@ public class ClusterServiceImpl implements IClusterService {
|
|||
*/
|
||||
@Override
|
||||
public Collection<IClusterMember> getMembers() {
|
||||
Set<Member> members = Activator.hazelcastInstance.getCluster().getMembers();
|
||||
Set<Member> members = Activator.getHazelcastInstance().getCluster().getMembers();
|
||||
Set<IClusterMember> clusterMembers = new HashSet<IClusterMember>();
|
||||
for(Member member : members) {
|
||||
clusterMembers.add(new ClusterMember(member.getUuid(), member.getInetSocketAddress().getAddress()));
|
||||
|
@ -50,7 +50,7 @@ public class ClusterServiceImpl implements IClusterService {
|
|||
*/
|
||||
@Override
|
||||
public IClusterMember getLocalMember() {
|
||||
Member member = Activator.hazelcastInstance.getCluster().getLocalMember();
|
||||
Member member = Activator.getHazelcastInstance().getCluster().getLocalMember();
|
||||
return new ClusterMember(member.getUuid(), member.getInetSocketAddress().getAddress());
|
||||
}
|
||||
|
||||
|
@ -59,11 +59,11 @@ public class ClusterServiceImpl implements IClusterService {
|
|||
*/
|
||||
@Override
|
||||
public <V> Future<V> execute(Callable<V> task, IClusterMember clusterMember) {
|
||||
Set<Member> members = Activator.hazelcastInstance.getCluster().getMembers();
|
||||
Set<Member> members = Activator.getHazelcastInstance().getCluster().getMembers();
|
||||
for(Member member : members) {
|
||||
if (member.getUuid().equals(clusterMember.getId())) {
|
||||
DistributedTask<V> distributedTask = new DistributedTask<V>(task, member);
|
||||
Activator.hazelcastInstance.getExecutorService().execute(distributedTask);
|
||||
Activator.getHazelcastInstance().getExecutorService().execute(distributedTask);
|
||||
return distributedTask;
|
||||
}
|
||||
}
|
||||
|
@ -81,7 +81,7 @@ public class ClusterServiceImpl implements IClusterService {
|
|||
for(IClusterMember clusterMember : clusterMembers) {
|
||||
selectedIds.add(clusterMember.getId());
|
||||
}
|
||||
Set<Member> members = Activator.hazelcastInstance.getCluster().getMembers();
|
||||
Set<Member> members = Activator.getHazelcastInstance().getCluster().getMembers();
|
||||
Set<Member> selectedMembers = new HashSet<Member>();
|
||||
for(Member member : members) {
|
||||
if (selectedIds.contains(member.getUuid())) {
|
||||
|
@ -90,7 +90,7 @@ public class ClusterServiceImpl implements IClusterService {
|
|||
}
|
||||
if (selectedMembers.size() > 0) {
|
||||
MultiTask<V> multiTask = new MultiTask<V>(task, selectedMembers);
|
||||
Activator.hazelcastInstance.getExecutorService().execute(multiTask);
|
||||
Activator.getHazelcastInstance().getExecutorService().execute(multiTask);
|
||||
return multiTask;
|
||||
}
|
||||
return null;
|
||||
|
|
|
@ -30,7 +30,7 @@ public class MessageServiceImpl implements IMessageService {
|
|||
|
||||
@Override
|
||||
public <T> ITopic<T> getTopic(String name) {
|
||||
com.hazelcast.core.ITopic<T> topic = Activator.hazelcastInstance.getTopic(name);
|
||||
com.hazelcast.core.ITopic<T> topic = Activator.getHazelcastInstance().getTopic(name);
|
||||
return new TopicImpl<T>(topic);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue