protected HAPartition findHAPartitionWithName (String name) throws Exception { return HAPartitionLocator.getHAPartitionLocator().getHAPartition(name, null); }
protected void startService() throws Exception { super.startService(); // Register with the service locator HAPartitionLocator.getHAPartitionLocator().registerHAPartition(this); // Bind ourself in the public JNDI space if configured to do so if (this.bindIntoJndi) { Context ctx = new InitialContext(); this.bind(HAPartitionLocator.getStandardJndiBinding(this.getPartitionName()), this, ClusterPartition.class, ctx); this.log.debug("Bound in JNDI under /HAPartition/" + this.getPartitionName()); } }
HAPartition partition = findInRegistry(partitionName); if (partition == null) partition = findInJndi(partitionName, jndiProperties);
protected void stopService() throws Exception { super.stopService(); if (this.bindIntoJndi) { String boundName = HAPartitionLocator.getStandardJndiBinding(this.getPartitionName()); InitialContext ctx = null; try { // the following statement fails when the server is being shut down (07/19/2007) ctx = new InitialContext(); ctx.unbind(boundName); } catch (Exception e) { this.log.error("partition unbind operation failed", e); } finally { if (ctx != null) { ctx.close(); } } NonSerializableFactory.unbind(boundName); } HAPartitionLocator.getHAPartitionLocator().deregisterHAPartition(this); }
/** * Find the given partition in JNDI under a * {@link #getStandardJndiBinding(String) standard binding}. * * @param partitionName the name of the partition. Cannot be <code>null</code>. * @return the partition, or <code>null</code> * * @throws NamingException if there is a problem with the naming context. Will * not throw NameNotFoundException; if not found, will * return <code>null</code>. * * @see #getStandardJndiBinding(String) */ protected HAPartition findInJndi(String partitionName, Hashtable<?, ?> jndiProperties) throws NamingException { try { Context ctx = new InitialContext(jndiProperties); return (HAPartition) ctx.lookup(getStandardJndiBinding(partitionName)); } catch (NameNotFoundException e) { // just not there return null; } } }
/** Initializes the cache for use. Prior to this the cache has no store. */ public void create() { // Lookup the parition HAPartition partition = HAPartitionLocator.getHAPartitionLocator().getHAPartition(this.partitionName, null); this.entryMap = partition.getDistributedStateService(); log.debug("Obtained DistributedState from partition=" + this.partitionName); this.now = System.currentTimeMillis(); }
@Override protected void startService() throws Exception { if (this.partition == null) { this.partition = HAPartitionLocator.getHAPartitionLocator().getHAPartition(this.partitionName, null); } // Register as a listener of cluster membership changes this.partition.registerMembershipListener(this); this.log.info("Registered as MembershipListener"); try { this.hostname = InetAddress.getLocalHost().getHostName(); } catch (IOException e) { this.log.warn("Failed to lookup local hostname", e); this.hostname = "<unknown>"; } }
/** Override the HttpProxyFactory method to create a HttpInvokerProxyHA. * @return an invoker proxy * @throws Exception */ protected Invoker createInvoker() throws Exception { HAPartition partition = HAPartitionLocator.getHAPartitionLocator().getHAPartition(partitionName, null); /* Create a HATarget for the local invoker mbean stub. The name passed to the HATarget must be the wrappedJmxInvokerName so that different 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); mbeanServer.registerMBean(invokerWrapper, wrappedJmxInvokerName); // Create the LoadBalancePolicy instance LoadBalancePolicy policy = (LoadBalancePolicy) policyClass.newInstance(); // Finally, create the invoker proxy, a HttpInvokerProxyHA String clusterFamilyName = partitionName + "/" + wrappedJmxInvokerName.toString(); Invoker delegateInvoker = new HttpInvokerProxyHA(invokerTarget.getReplicantList(), invokerTarget.getCurrentViewId (), policy, clusterFamilyName); return delegateInvoker; }
protected void setupInvokers() throws Exception HAPartition partition = HAPartitionLocator.getHAPartitionLocator().getHAPartition(partitionName, null); this.drm = partition.getDistributedReplicantManager ();
HAPartition partition = HAPartitionLocator.getHAPartitionLocator().getHAPartition(partitionName, null);