Upgrading clustermanager to use infinispan 6.0.2Final. 57/5957/4
authorRavikumar Chiguruvada <ravikumar.chiguruvada@ericsson.com>
Tue, 8 Apr 2014 10:34:56 +0000 (16:04 +0530)
committerGiovanni Meo <gmeo@cisco.com>
Wed, 9 Apr 2014 13:13:49 +0000 (15:13 +0200)
- Removed unnecessary BaseInterceptor clone which was needed for 5.3.0
version
- Bumped services_implementation implementation version to indicate
this is actually different.
- Modified the parent pom version so version propagate in other places

Signed-off-by: Ravikumar Chiguruvada <ravikumar.chiguruvada@ericsson.com>
Signed-off-by: Giovanni Meo <gmeo@cisco.com>
Change-Id: I062c72153a2ffe6949f3a3c8d2f0cdaa826bb65c

opendaylight/clustering/services_implementation/pom.xml
opendaylight/clustering/services_implementation/src/main/java/org/infinispan/interceptors/distribution/BaseDistributionInterceptor.java [deleted file]
opendaylight/clustering/services_implementation/src/main/resources/config/infinispan-config.xml
opendaylight/commons/opendaylight/pom.xml

index d7a3db3841888f3c08e5cf8795aa42cf9cd9b4bc..1b72630b8c2fdfbeaaee851c57fe6076cdfafe8e 100644 (file)
@@ -15,7 +15,7 @@
   </scm>
 
   <artifactId>clustering.services-implementation</artifactId>
-  <version>0.4.2-SNAPSHOT</version>
+  <version>0.4.3-SNAPSHOT</version>
   <packaging>bundle</packaging>
   <properties>
     <!-- Sonar properties using jacoco to retrieve integration test results -->
@@ -68,7 +68,7 @@
               *
             </DynamicImport-Package>
             <Embed-Dependency>
-              infinispan-core,jgroups,jboss-marshalling-river,jboss-marshalling,jboss-logging,staxmapper,narayana-jta;type=!pom;inline=false
+              infinispan-core,infinispan-commons,jgroups,jboss-marshalling-river,jboss-marshalling,jboss-logging,staxmapper,narayana-jta;type=!pom;inline=false
             </Embed-Dependency>
             <Embed-Transitive>
               true
                     <exclude>org.infinispan:infinispan-core:*</exclude>
                   </excludes>
                   <includes>
-                    <include>org.infinispan:infinispan-core:[5.3.0.Final]</include>
+                    <include>org.infinispan:infinispan-core:[6.0.2.Final]</include>
                   </includes>
                 </bannedDependencies>
               </rules>
     <dependency>
       <groupId>org.infinispan</groupId>
       <artifactId>infinispan-core</artifactId>
-      <version>5.3.0.Final</version>
+      <version>6.0.2.Final</version>
     </dependency>
     <dependency>
       <groupId>org.opendaylight.controller</groupId>
diff --git a/opendaylight/clustering/services_implementation/src/main/java/org/infinispan/interceptors/distribution/BaseDistributionInterceptor.java b/opendaylight/clustering/services_implementation/src/main/java/org/infinispan/interceptors/distribution/BaseDistributionInterceptor.java
deleted file mode 100644 (file)
index d495e45..0000000
+++ /dev/null
@@ -1,252 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2009 Red Hat Inc. and/or its affiliates and other
- * contributors as indicated by the @author tags. All rights reserved.
- * See the copyright.txt in the distribution for a full listing of
- * individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.infinispan.interceptors.distribution;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-import org.infinispan.CacheException;
-import org.infinispan.commands.FlagAffectedCommand;
-import org.infinispan.commands.remote.ClusteredGetCommand;
-import org.infinispan.commands.write.DataWriteCommand;
-import org.infinispan.commands.write.WriteCommand;
-import org.infinispan.container.entries.InternalCacheEntry;
-import org.infinispan.container.entries.InternalCacheValue;
-import org.infinispan.context.InvocationContext;
-import org.infinispan.context.impl.TxInvocationContext;
-import org.infinispan.distribution.DistributionManager;
-import org.infinispan.factories.annotations.Inject;
-import org.infinispan.interceptors.ClusteringInterceptor;
-import org.infinispan.interceptors.locking.ClusteringDependentLogic;
-import org.infinispan.remoting.responses.ClusteredGetResponseValidityFilter;
-import org.infinispan.remoting.responses.ExceptionResponse;
-import org.infinispan.remoting.responses.Response;
-import org.infinispan.remoting.responses.SuccessfulResponse;
-import org.infinispan.remoting.rpc.ResponseFilter;
-import org.infinispan.remoting.rpc.ResponseMode;
-import org.infinispan.remoting.rpc.RpcOptions;
-import org.infinispan.remoting.transport.Address;
-import org.infinispan.transaction.xa.GlobalTransaction;
-import org.infinispan.util.logging.Log;
-import org.infinispan.util.logging.LogFactory;
-
-
-/**
- * Base class for distribution of entries across a cluster.
- *
- * @author Manik Surtani
- * @author Mircea.Markus@jboss.com
- * @author Pete Muir
- * @author Dan Berindei <dan@infinispan.org>
- * @since 4.0
- */
-public abstract class BaseDistributionInterceptor extends ClusteringInterceptor {
-
-   protected DistributionManager dm;
-
-   protected ClusteringDependentLogic cdl;
-
-   private static final Log log = LogFactory.getLog(BaseDistributionInterceptor.class);
-
-   @Override
-   protected Log getLog() {
-      return log;
-   }
-
-   @Inject
-   public void injectDependencies(DistributionManager distributionManager, ClusteringDependentLogic cdl) {
-      this.dm = distributionManager;
-      this.cdl = cdl;
-   }
-
-   @Override
-   protected final InternalCacheEntry retrieveFromRemoteSource(Object key, InvocationContext ctx, boolean acquireRemoteLock, FlagAffectedCommand command) throws Exception {
-      GlobalTransaction gtx = acquireRemoteLock ? ((TxInvocationContext)ctx).getGlobalTransaction() : null;
-      ClusteredGetCommand get = cf.buildClusteredGetCommand(key, command.getFlags(), acquireRemoteLock, gtx);
-
-      List<Address> targets = new ArrayList<Address>(stateTransferManager.getCacheTopology().getReadConsistentHash().locateOwners(key));
-      // if any of the recipients has left the cluster since the command was issued, just don't wait for its response
-      targets.retainAll(rpcManager.getTransport().getMembers());
-      ResponseFilter filter = new ClusteredGetResponseValidityFilter(targets, rpcManager.getAddress());
-      RpcOptions options = rpcManager.getRpcOptionsBuilder(ResponseMode.WAIT_FOR_VALID_RESPONSE, false)
-            .responseFilter(filter).build();
-      Map<Address, Response> responses = rpcManager.invokeRemotely(targets, get, options);
-
-      if (!responses.isEmpty()) {
-         for (Response r : responses.values()) {
-            if (r instanceof SuccessfulResponse) {
-               InternalCacheValue cacheValue = (InternalCacheValue) ((SuccessfulResponse) r).getResponseValue();
-               return cacheValue.toInternalCacheEntry(key);
-            }
-         }
-      }
-
-      // TODO If everyone returned null, and the read CH has changed, retry the remote get.
-      // Otherwise our get command might be processed by the old owners after they have invalidated their data
-      // and we'd return a null even though the key exists on
-      return null;
-   }
-
-   protected final Object handleNonTxWriteCommand(InvocationContext ctx, DataWriteCommand command) throws Throwable {
-      if (ctx.isInTxScope()) {
-         throw new CacheException("Attempted execution of non-transactional write command in a transactional invocation context");
-      }
-
-      RecipientGenerator recipientGenerator = new SingleKeyRecipientGenerator(command.getKey());
-
-      // see if we need to load values from remote sources first
-      remoteGetBeforeWrite(ctx, command, recipientGenerator);
-
-      // if this is local mode then skip distributing
-      if (isLocalModeForced(command)) {
-         return invokeNextInterceptor(ctx, command);
-      }
-
-      boolean isSync = isSynchronous(command);
-      if (!ctx.isOriginLocal()) {
-         Object returnValue = invokeNextInterceptor(ctx, command);
-         Address primaryOwner = cdl.getPrimaryOwner(command.getKey());
-            if (primaryOwner.equals(rpcManager.getAddress())) {
-                if (command.isConditional() && !command.isSuccessful()) {
-                    log.tracef(
-                            "Skipping the replication of the conditional command as it did not succeed on primary owner (%s).",
-                            command);
-                    return returnValue;
-                }
-                rpcManager.invokeRemotely(recipientGenerator.generateRecipients(), command,
-                        rpcManager.getDefaultRpcOptions(isSync));
-            } else {
-                log.tracef("Didn't invoke RPC because primaryOwner (%s) didn't match this node (%s)", primaryOwner,
-                           rpcManager.getAddress());
-                log.tracef("Hashcode is (%s) for Key (%s)",
-                           command.getKey().hashCode(), command.getKey());
-            }
-         return returnValue;
-      } else {
-         Address primaryOwner = cdl.getPrimaryOwner(command.getKey());
-         if (primaryOwner.equals(rpcManager.getAddress())) {
-            Object result = invokeNextInterceptor(ctx, command);
-            if (command.isConditional() && !command.isSuccessful()) {
-               log.tracef("Skipping the replication of the conditional command as it did not succeed on primary owner (%s).", command);
-               return result;
-            }
-            List<Address> recipients = recipientGenerator.generateRecipients();
-            log.tracef("I'm the primary owner, sending the command to all (%s) the recipients in order to be applied.", recipients);
-            // check if a single owner has been configured and the target for the key is the local address
-            boolean isSingleOwnerAndLocal = cacheConfiguration.clustering().hash().numOwners() == 1
-                  && recipients != null
-                  && recipients.size() == 1
-                  && recipients.get(0).equals(rpcManager.getTransport().getAddress());
-            if (!isSingleOwnerAndLocal) {
-               rpcManager.invokeRemotely(recipients, command, rpcManager.getDefaultRpcOptions(isSync));
-            }
-            return result;
-         } else {
-            log.tracef("I'm not the primary owner, so sending the command to the primary owner(%s) in order to be forwarded", primaryOwner);
-            log.tracef("Hashcode is (%s) for Key (%s)", command.getKey().hashCode(), command.getKey());
-
-            Object localResult = invokeNextInterceptor(ctx, command);
-            boolean isSyncForwarding = isSync || isNeedReliableReturnValues(command);
-            Map<Address, Response> addressResponseMap = rpcManager.invokeRemotely(Collections.singletonList(primaryOwner), command,
-                  rpcManager.getDefaultRpcOptions(isSyncForwarding));
-            if (!isSyncForwarding) return localResult;
-
-            return getResponseFromPrimaryOwner(primaryOwner, addressResponseMap);
-         }
-      }
-   }
-
-   private Object getResponseFromPrimaryOwner(Address primaryOwner, Map<Address, Response> addressResponseMap) {
-      Response fromPrimaryOwner = addressResponseMap.get(primaryOwner);
-      if (fromPrimaryOwner == null) {
-         log.tracef("Primary owner %s returned null", primaryOwner);
-         return null;
-      }
-      if (!fromPrimaryOwner.isSuccessful()) {
-         Throwable cause = fromPrimaryOwner instanceof ExceptionResponse ? ((ExceptionResponse)fromPrimaryOwner).getException() : null;
-         throw new CacheException("Got unsuccessful response from primary owner: " + fromPrimaryOwner, cause);
-      } else {
-         return ((SuccessfulResponse) fromPrimaryOwner).getResponseValue();
-      }
-   }
-
-   protected abstract void remoteGetBeforeWrite(InvocationContext ctx, WriteCommand command, RecipientGenerator keygen) throws Throwable;
-
-   interface RecipientGenerator {
-
-      Collection<Object> getKeys();
-
-      List<Address> generateRecipients();
-   }
-
-   class SingleKeyRecipientGenerator implements RecipientGenerator {
-      private final Object key;
-      private final Set<Object> keys;
-      private List<Address> recipients = null;
-
-      SingleKeyRecipientGenerator(Object key) {
-         this.key = key;
-         keys = Collections.singleton(key);
-      }
-
-      @Override
-      public List<Address> generateRecipients() {
-         if (recipients == null) {
-            recipients = cdl.getOwners(key);
-         }
-         return recipients;
-      }
-
-      @Override
-      public Collection<Object> getKeys() {
-         return keys;
-      }
-   }
-
-   class MultipleKeysRecipientGenerator implements RecipientGenerator {
-
-      private final Collection<Object> keys;
-      private List<Address> recipients = null;
-
-      MultipleKeysRecipientGenerator(Collection<Object> keys) {
-         this.keys = keys;
-      }
-
-      @Override
-      public List<Address> generateRecipients() {
-         if (recipients == null) {
-            recipients = cdl.getOwners(keys);
-         }
-         return recipients;
-      }
-
-      @Override
-      public Collection<Object> getKeys() {
-         return keys;
-      }
-   }
-}
index 5ec4325c7f83a665ffc54d0de10b8a7ea0e31ebe..5fb0ddff609a8fbbaa7fce1601392cc007e5ff33 100644 (file)
@@ -1,4 +1,4 @@
-<infinispan xsi:schemaLocation="urn:infinispan:config:5.3 http://www.infinispan.org/schemas/infinispan-config-5.3.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="urn:infinispan:config:5.3">
+<infinispan>
   <global>
     <transport>
       <properties>
         jmxDomain="org.infinispan"
         cacheManagerName="SampleCacheManager"/>
   </global>
-  <default>
-    <!-- Configure a synchronous replication cache -->
-    <clustering mode="replication">
-      <sync/>
-    </clustering>
-    <!--
-        Used to register JMX statistics in any available MBean server
-    -->
+
+ <default>
     <jmxStatistics enabled="true"/>
-  </default>
-  <!-- transactionManagerLookupClass="org.infinispan.transaction.lookup.JBossStandaloneJTAManagerLookup" -->
-  <namedCache name="transactional-type">
+        <clustering mode="replication">
+        <sync/>
+        </clustering>
+        </default>
+ <namedCache name="transactional-type">
     <transaction
         transactionManagerLookupClass="org.infinispan.transaction.lookup.JBossStandaloneJTAManagerLookup"
         syncRollbackPhase="true"
         use1PcForAutoCommitTransactions="true"
         autoCommit="true"
         lockingMode="OPTIMISTIC"
+        useEagerLocking="true"
         useSynchronization="true"
         transactionMode="TRANSACTIONAL"
         />
+        <clustering mode="replication">
+        <sync/>
+        </clustering>
   </namedCache>
+
 </infinispan>
index 3690b8542bc0d5b867fdc0a5bcc42a62fa99bf19..e638ba68a7655529ab34d52957b6b883cc5d42ef 100644 (file)
     <topologymanager.version>0.4.2-SNAPSHOT</topologymanager.version>
     <protocol_plugin.stub.version>0.4.2-SNAPSHOT</protocol_plugin.stub.version>
     <clustering.stub.version>0.4.2-SNAPSHOT</clustering.stub.version>
+    <clustering.services_implementation.version>0.4.3-SNAPSHOT</clustering.services_implementation.version>
     <!-- Third party version -->
     <jersey-servlet.version>1.17</jersey-servlet.version>
     <corsfilter.version>7.0.42</corsfilter.version>
       <dependency>
         <groupId>org.opendaylight.controller</groupId>
         <artifactId>clustering.services-implementation</artifactId>
-        <version>${controller.version}</version>
+        <version>${clustering.services_implementation.version}</version>
       </dependency>
       <dependency>
         <groupId>org.opendaylight.controller</groupId>