Package org.jboss.ha.framework.server

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


   public Invoker createProxy(ObjectName targetName, LoadBalancePolicy policy,
                              String proxyFamilyName)
      throws Exception
   {
      Integer hash = new Integer(targetName.hashCode());
      HATarget target = (HATarget) targetMap.get(hash);
      if (target == null)
      {
         throw new IllegalStateException("The targetName("+targetName
            + "), hashCode("+hash+") not found");
      }
      Invoker proxy = new HttpInvokerProxyHA(target.getReplicantList(), target.getCurrentViewId (),
                                             policy, proxyFamilyName);
      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 = targetMap.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[] args = {invocation};
         String[] sig = {"org.jboss.invocation.Invocation"};
         Object rtn = super.getServer().invoke(mbean,
            "invoke", args, sig);

         // Update the targets list if the client view is out of date
         HARMIResponse rsp = new HARMIResponse();
         if (clientViewId != target.getCurrentViewId())
         {
            rsp.newReplicants = new ArrayList<Object>(target.getReplicantList());
            rsp.currentViewId = target.getCurrentViewId();
         }
         rsp.response = rtn;

         // Return the raw object and let the http layer marshall it
         return rsp;
View Full Code Here

      more than one HttpProxyFactoryHA may be configured for the same
      realJmxInvokerName.
      */
      checkInvokerURL();
      Serializable invokerStub = super.getInvokerURL();
      invokerTarget = new HATarget(partition, wrappedJmxInvokerName.toString(),
         invokerStub, HATarget.MAKE_INVOCATIONS_WAIT);
      log.debug("Created invoker: "+invokerTarget);
      // Create and register the invoker wrapper
      MBeanServer mbeanServer = super.getServer();
      invokerWrapper = new HAInvokerWrapper(mbeanServer, realJmxInvokerName, invokerTarget);
View Full Code Here

         throw new RuntimeException("Invoker is not registered: " + getInvokerName());

      int mode = HATarget.MAKE_INVOCATIONS_WAIT;
      if (state == ServiceMBean.STARTED)
         mode = HATarget.ENABLE_INVOCATIONS;
      target = new HATarget(partition, replicantName, invokerHA.getStub(), mode);
      invokerHA.registerBean(getServiceName(), target);

      String clusterFamilyName = partitionName + "/" + getTargetName() + "/";
     
      // make ABSOLUTLY sure we do register with the DRM AFTER the HATarget
View Full Code Here

      jrmp = (InvokerHA)Registry.lookup(oname);
      if (jrmp == null)
         throw new RuntimeException("home JRMPInvokerHA is null: " + oname);


      target = new HATarget(partition, replicantName, jrmp.getStub (), HATarget.MAKE_INVOCATIONS_WAIT);
      jrmp.registerBean(jmxName, target);

      String clusterFamilyName = partitionName + "/" + jmxName + "/";
     
      // make ABSOLUTLY sure we do register with the DRM AFTER the HATarget
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;
      }

      return createProxy(getStrictRMIException(),
            target.getReplicantList(), policy, proxyFamilyName, target.getCurrentViewId());
   }
View Full Code Here

      {
         mbean = (ObjectName) Registry.lookup(invocation.getObjectName());

         /** Clustering **/
         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");
         }
         /** End Clustering **/

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

         /** Clustering **/

         HARMIResponse haResponse = new HARMIResponse();

         if(clientViewId != target.getCurrentViewId())
         {
            haResponse.newReplicants = new ArrayList<Object>(target.getReplicantList());
            haResponse.currentViewId = target.getCurrentViewId();
         }
         haResponse.response = obj;

         /** End Clustering **/

 
View Full Code Here

   throws Exception
   {
      String proxyFamilyName = objectId.toString() + locator.getProtocol() + partitionName;
      HAPartition partition = HAPartitionLocator.getHAPartitionLocator().getHAPartition(partitionName, null);

      HATarget target = null;
      Map families = null;
      InstanceAdvisor advisor = null;
      Class clazz;

      if (obj instanceof Advised)
      {
         advisor = ((Advised) obj)._getInstanceAdvisor();
         clazz = obj.getClass();
         Dispatcher.singleton.registerTarget(objectId, obj);
      }
      else
      {
         clazz = obj.getClass();
         ClassProxy proxy = ClassProxyFactory.newInstance(obj.getClass());
         advisor = proxy._getInstanceAdvisor();
         advisor.insertInterceptor(new ForwardingInterceptor(obj));
         Dispatcher.singleton.registerTarget(objectId, proxy);
      }
      families = (Map) advisor.getMetaData().getMetaData(CLUSTERED_REMOTING, CLUSTER_FAMILIES);
      if (families != null)
      {
         target = (HATarget) families.get(proxyFamilyName);
         if (target == null)
         {
            target = new HATarget(partition, proxyFamilyName, locator, HATarget.ENABLE_INVOCATIONS);
            ClusteringTargetsRepository.initTarget(proxyFamilyName, target.getReplicantList());
            families.put(proxyFamilyName, target);
         }
      }
      else
      {
         families = new HashMap();
         target = new HATarget(partition, proxyFamilyName, locator, HATarget.ENABLE_INVOCATIONS);
         ClusteringTargetsRepository.initTarget(proxyFamilyName, target.getReplicantList());
         families.put(proxyFamilyName, target);
         advisor.insertInterceptor(0, new ReplicantsManagerInterceptor(families));
      }

      ClassProxy proxy = ClassProxyFactory.newInstance(clazz);
      InstanceAdvisor proxyAdvisor = proxy._getInstanceAdvisor();
      proxyAdvisor.insertInterceptor(IsLocalInterceptor.singleton);
      advisor.insertInterceptor(SecurityClientInterceptor.singleton);
      advisor.insertInterceptor(ClientTxPropagationInterceptor.singleton);
      proxyAdvisor.insertInterceptor(MergeMetaDataInterceptor.singleton);
      proxyAdvisor.insertInterceptor(ClusterChooserInterceptor.singleton);
      proxyAdvisor.insertInterceptor(InvokeRemoteInterceptor.singleton);

      proxyAdvisor.getMetaData().addMetaData(CLUSTERED_REMOTING,
      CLUSTER_FAMILY_WRAPPER,
      new FamilyWrapper(proxyFamilyName, target.getReplicantList()),
      PayloadKey.AS_IS);

      // LB policy should be AS_IS so that remoting framework downloads the classes
      proxyAdvisor.getMetaData().addMetaData(CLUSTERED_REMOTING,
      LOADBALANCE_POLICY,
View Full Code Here

         advisor = registeredObject._getInstanceAdvisor();
         Map families = (Map) advisor.getMetaData().getMetaData(CLUSTERED_REMOTING, CLUSTER_FAMILIES);
         Iterator it = families.values().iterator();
         while (it.hasNext())
         {
            HATarget target = (HATarget) it.next();
            target.destroy();
         }
      }
      catch (Exception ignored)
      {
         log.trace("Ignored exception unregistering a clustered object", ignored);
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

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.