Package org.jboss.ha.framework.server

Examples of org.jboss.ha.framework.server.HATarget


/*     */     throws Exception
/*     */   {
/*  58 */     String proxyFamilyName = objectId.toString() + locator.getProtocol() + partitionName;
/*  59 */     HAPartition partition = (HAPartition)new InitialContext().lookup("/HAPartition/" + partitionName);
/*     */
/*  61 */     HATarget target = null;
/*  62 */     Map families = null;
/*  63 */     InstanceAdvisor advisor = null;
/*     */     Class clazz;
/*  66 */     if ((obj instanceof Advised))
/*     */     {
/*  68 */       advisor = ((Advised)obj)._getInstanceAdvisor();
/*  69 */       Class clazz = obj.getClass();
/*  70 */       Dispatcher.singleton.registerTarget(objectId, obj);
/*     */     }
/*     */     else
/*     */     {
/*  74 */       clazz = obj.getClass();
/*  75 */       ClassProxy proxy = ClassProxyFactory.newInstance(obj.getClass());
/*  76 */       advisor = proxy._getInstanceAdvisor();
/*  77 */       advisor.insertInterceptor(new ForwardingInterceptor(obj));
/*  78 */       Dispatcher.singleton.registerTarget(objectId, proxy);
/*     */     }
/*  80 */     families = (Map)advisor.getMetaData().getMetaData("CLUSTERED_REMOTING", "CLUSTER_FAMILIES");
/*  81 */     if (families != null)
/*     */     {
/*  83 */       target = (HATarget)families.get(proxyFamilyName);
/*  84 */       if (target == null)
/*     */       {
/*  86 */         target = new HATarget(partition, proxyFamilyName, locator, 2);
/*  87 */         ClusteringTargetsRepository.initTarget(proxyFamilyName, target.getReplicants());
/*  88 */         families.put(proxyFamilyName, target);
/*     */       }
/*     */     }
/*     */     else
/*     */     {
/*  93 */       families = new HashMap();
/*  94 */       target = new HATarget(partition, proxyFamilyName, locator, 2);
/*  95 */       ClusteringTargetsRepository.initTarget(proxyFamilyName, target.getReplicants());
/*  96 */       families.put(proxyFamilyName, target);
/*  97 */       advisor.insertInterceptor(0, new ReplicantsManagerInterceptor(families));
/*     */     }
/*     */
/* 100 */     ClassProxy proxy = ClassProxyFactory.newInstance(clazz);
/* 101 */     InstanceAdvisor proxyAdvisor = proxy._getInstanceAdvisor();
/* 102 */     proxyAdvisor.insertInterceptor(IsLocalInterceptor.singleton);
/* 103 */     advisor.insertInterceptor(SecurityClientInterceptor.singleton);
/* 104 */     advisor.insertInterceptor(ClientTxPropagationInterceptor.singleton);
/* 105 */     proxyAdvisor.insertInterceptor(MergeMetaDataInterceptor.singleton);
/* 106 */     proxyAdvisor.insertInterceptor(ClusterChooserInterceptor.singleton);
/* 107 */     proxyAdvisor.insertInterceptor(InvokeRemoteInterceptor.singleton);
/*     */
/* 109 */     proxyAdvisor.getMetaData().addMetaData("CLUSTERED_REMOTING", "CLUSTER_FAMILY_WRAPPER", new FamilyWrapper(proxyFamilyName, target.getReplicants()), PayloadKey.AS_IS);
/*     */
/* 115 */     proxyAdvisor.getMetaData().addMetaData("CLUSTERED_REMOTING", "LOADBALANCE_POLICY", lb, PayloadKey.AS_IS);
/*     */
/* 120 */     proxyAdvisor.getMetaData().addMetaData("REMOTING", "SUBSYSTEM", "AOP", PayloadKey.AS_IS);
/*     */
View Full Code Here


/* 145 */       advisor = registeredObject._getInstanceAdvisor();
/* 146 */       Map families = (Map)advisor.getMetaData().getMetaData("CLUSTERED_REMOTING", "CLUSTER_FAMILIES");
/* 147 */       Iterator it = families.values().iterator();
/* 148 */       while (it.hasNext())
/*     */       {
/* 150 */         HATarget target = (HATarget)it.next();
/* 151 */         target.destroy();
/*     */       }
/*     */     }
/*     */     catch (Exception ignored)
/*     */     {
/* 156 */       log.trace("Ignored exception unregistering a clustered object", ignored);
View Full Code Here

/*  98 */     String clientBindUrl = ProxyFactoryHelper.getClientBindUrl(this.binding);
/*  99 */     this.locator = new InvokerLocator(clientBindUrl);
/* 100 */     String partitionName = ((SessionContainer)getContainer()).getPartitionName();
/* 101 */     this.proxyFamilyName = (((SessionContainer)getContainer()).getDeploymentQualifiedName() + this.locator.getProtocol() + partitionName);
/* 102 */     HAPartition partition = (HAPartition)getContainer().getInitialContext().lookup("/HAPartition/" + partitionName);
/* 103 */     this.hatarget = new HATarget(partition, this.proxyFamilyName, this.locator, 2);
/* 104 */     ClusteringTargetsRepository.initTarget(this.proxyFamilyName, this.hatarget.getReplicants());
/* 105 */     ((SessionContainer)getContainer()).getClusterFamilies().put(this.proxyFamilyName, this.hatarget);
/* 106 */     if ((this.clustered.loadBalancePolicy() == null) || (this.clustered.loadBalancePolicy().equals(LoadBalancePolicy.class)))
/*     */     {
/* 108 */       this.lbPolicy = new FirstAvailable();
View Full Code Here

      SessionContainer container = this.getContainer();
      partitionName = container.getPartitionName();
      proxyFamilyName = container.getDeploymentQualifiedName() + locator.getProtocol() + partitionName;
      partition = HAPartitionLocator.getHAPartitionLocator().getHAPartition(partitionName, container.getInitialContextProperties());
      drm = partition.getDistributedReplicantManager();
      hatarget = new HATarget(partition, proxyFamilyName, locator, HATarget.ENABLE_INVOCATIONS);
      ClusteringTargetsRepository.initTarget(proxyFamilyName, hatarget.getReplicants());
      container.getClusterFamilies().put(proxyFamilyName, hatarget);
     
      if (clustered.loadBalancePolicy() == null || clustered.loadBalancePolicy().equals(ClusteredDefaults.LOAD_BALANCE_POLICY_DEFAULT))
      {
View Full Code Here

      InvokerLocator locator = this.getLocator();
      SessionContainer container = this.getContainer();
      String partitionName = container.getPartitionName();
      proxyFamilyName = container.getDeploymentQualifiedName() + locator.getProtocol() + partitionName;
      HAPartition partition = HAPartitionLocator.getHAPartitionLocator().getHAPartition(partitionName, container.getInitialContextProperties());
      hatarget = new HATarget(partition, proxyFamilyName, locator, HATarget.ENABLE_INVOCATIONS);
      ClusteringTargetsRepository.initTarget(proxyFamilyName, hatarget.getReplicants());
      container.getClusterFamilies().put(proxyFamilyName, hatarget);
     
      if (clustered.loadBalancePolicy() == null || clustered.loadBalancePolicy().equals(ClusteredDefaults.LOAD_BALANCE_POLICY_DEFAULT))
      {
View Full Code Here

      locator = new InvokerLocator(clientBindUrl);
      StatelessContainer container = (StatelessContainer) getContainer();
      String partitionName = container.getPartitionName();
      proxyFamilyName = container.getDeploymentQualifiedName() + locator.getProtocol() + partitionName;
      HAPartition partition = HAPartitionLocator.getHAPartitionLocator().getHAPartition(partitionName, container.getInitialContextProperties());
      hatarget = new HATarget(partition, proxyFamilyName, locator, HATarget.ENABLE_INVOCATIONS);
      ClusteringTargetsRepository.initTarget(proxyFamilyName, hatarget.getReplicants());
     
      container.getClusterFamilies().put(proxyFamilyName, hatarget);
     
      if (clustered.loadBalancePolicy() == null || clustered.loadBalancePolicy().equals(ClusteredDefaults.LOAD_BALANCE_POLICY_DEFAULT))
View Full Code Here

   public Object invoke(org.jboss.aop.joinpoint.Invocation invocation) throws Throwable
   {
      Object response = invocation.invokeNext();
      String clientFamily = (String) invocation.getMetaData(CLUSTERED_REMOTING, CLUSTER_FAMILY);

      HATarget target = (HATarget) families.get(clientFamily);
      if (target == null)
      {
         return response;
      }

      Long clientViewId = (Long) invocation.getMetaData(CLUSTERED_REMOTING, CLUSTER_VIEW_ID);
      if (clientViewId == null)
      {
         // Maybe we're being invoked upon by a non-clustered proxy
         return response;
      }
      if (clientViewId.longValue() != target.getCurrentViewId())
      {
         invocation.addResponseAttachment("replicants", new ArrayList(target.getReplicants()));
         invocation.addResponseAttachment("viewId", new Long(target.getCurrentViewId()));
      }
      return response;
   }
View Full Code Here

   public Object invoke(Invocation invocation) throws Throwable
   {
      Object response = invocation.invokeNext();
      String clientFamily = (String) invocation.getMetaData(CLUSTERED_REMOTING, CLUSTER_FAMILY);

      HATarget target = (HATarget) families.get(clientFamily);
      if (target == null)
      {
         return response;
      }

      Long clientViewId = (Long) invocation.getMetaData(CLUSTERED_REMOTING, CLUSTER_VIEW_ID);
      if (clientViewId == null)
      {
         // Maybe we're being invoked upon by a non-clustered proxy
         return response;
      }
      if (clientViewId.longValue() != target.getCurrentViewId())
      {
         invocation.addResponseAttachment("replicants", new ArrayList<Object>(target.getReplicants()));
         invocation.addResponseAttachment("viewId", new Long(target.getCurrentViewId()));
      }
      return response;
   }
View Full Code Here

  
   public Invoker createProxy(ObjectName beanName, LoadBalancePolicy policy,
      String proxyFamilyName) throws Exception
   {
      Integer hash = new Integer(beanName.hashCode());
      HATarget target = (HATarget) beanMap.get(hash);
      if (target == null)
      {
         throw new IllegalStateException("The bean hashCode not found");
      }

      String familyName = proxyFamilyName;
      if (familyName == null)
         familyName= target.getAssociatedPartition().getPartitionName() + "/" + beanName;

      JRMPInvokerProxyHA proxy = new JRMPInvokerProxyHA(target.getReplicants(),
                                                        policy,
                                                        familyName,
                                                        target.getCurrentViewId ());
      return proxy;
   }
View Full Code Here

         // Extract the ObjectName, the rest is still marshalled
         ObjectName mbean = (ObjectName) Registry.lookup(invocation.getObjectName());
         long clientViewId = ((Long)invocation.getValue("CLUSTER_VIEW_ID")).longValue();

         HATarget target = (HATarget)beanMap.get(invocation.getObjectName());
         if (target == null)
         {
            // We could throw IllegalStateException but we have a race condition that could occur:
            // when we undeploy a bean, the cluster takes some time to converge
            // and to recalculate a new viewId and list of replicant for each HATarget.
            // Consequently, a client could own an up-to-date list of the replicants
            // (before the cluster has converged) and try to perform an invocation
            // on this node where the HATarget no more exist, thus receiving a
            // wrong exception and no failover is performed with an IllegalStateException
            //
            throw new GenericClusteringException(GenericClusteringException.COMPLETED_NO,
                                                 "target is not/no more registered on this node");           
         }
        
         if (!target.invocationsAllowed ())
            throw new GenericClusteringException(GenericClusteringException.COMPLETED_NO,
                                        "invocations are currently not allowed on this target");           

         // The cl on the thread should be set in another interceptor
         Object rtn = getServer().invoke(mbean,
                                         "invoke",
                                         new Object[] { invocation },
                                         Invocation.INVOKE_SIGNATURE);
        
         HARMIResponse rsp = new HARMIResponse();

         if (clientViewId != target.getCurrentViewId())
         {
            rsp.newReplicants = new ArrayList(target.getReplicants());
            rsp.currentViewId = target.getCurrentViewId();
         }
         rsp.response = rtn;
         return rsp;
      }
      catch (InstanceNotFoundException e)
View Full Code Here

TOP

Related Classes of org.jboss.ha.framework.server.HATarget

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.