Collect the RPC server information.

@param rpcServerMetricsModel server information model
761233
public void collectServer(RpcServerLookoutModel rpcServerMetricsModel) {

        try {
            Id methodProviderId = createMethodProviderId(rpcServerMetricsModel);
            MixinMetric methodProviderMetric = Lookout.registry().mixinMetric(methodProviderId);

            recordCounterAndTimer(methodProviderMetric, rpcServerMetricsModel);

        } catch (Throwable t) {
            LOGGER.error(LogCodes.getLog(LogCodes.ERROR_METRIC_REPORT_ERROR), t);
        }
    }
1186351
public void doPost(AtmosphereResource ar) {
        Object msg = ar.getRequest().getAttribute(Constants.MESSAGE_OBJECT);
        if (msg != null) {
          logger.info("received RPC post: " + msg.toString());
          // for demonstration purposes we will broadcast the message to all connections
            ar.getAtmosphereConfig().getBroadcasterFactory().lookup("MyBroadcaster").broadcast(msg);
        }
    }
1140179
void processServerFeaturesRequest(Result featureResolveResult) {

        final Set<String> serverFeatureNames = new HashSet<String>();
        serverFeatureNames.addAll(featureResolveResult.getResolvedFeatures());
        serverFeatureNames.addAll(featureResolveResult.getMissing());

        //publish the service that will be used by the launcher to read back the data.
        final Dictionary<String, Object> d = new Hashtable<String, Object>();

        bundleContext.registerService(ServerFeatures.class, new ServerFeatures() {
            @Override
            public String[] getServerFeatureNames() {
                //return newly filtered data
                return serverFeatureNames.toArray(new String[serverFeatureNames.size()]);
            }
        }, d);

        //we're done here.. let liberty proceed to declare itself 'started' =)
    }
760786
public void collectRequestStats(HttpRequestInfo req) {
        // ipv4/ipv6 tracking
        String clientIp;
        final String xForwardedFor = req.getHeaders().getFirst(X_FORWARDED_FOR_HEADER);
        if (xForwardedFor == null) {
            clientIp = req.getClientIp();
        } else {
            clientIp = extractClientIpFromXForwardedFor(xForwardedFor);
        }

        final boolean isIPv6 = (clientIp != null) ? isIPv6(clientIp) : false;

        final String ipVersionKey = isIPv6 ? "ipv6" : "ipv4";
        incrementNamedCountingMonitor(ipVersionKey, ipVersionCounterMap);

        // host header
        String host = req.getHeaders().getFirst(HOST_HEADER);
        if (host != null) {
            int colonIdx;
            if (isIPv6) {
                // an ipv6 host might be a raw IP with 7+ colons
                colonIdx = host.lastIndexOf(":");
            } else {
                // strips port from host
                colonIdx = host.indexOf(":");
            }
            if (colonIdx > -1) host = host.substring(0, colonIdx);
            incrementNamedCountingMonitor(hostKey(host), this.hostCounterMap);
        }

        // http vs. https
        String protocol = req.getHeaders().getFirst(X_FORWARDED_PROTO_HEADER);
        if (protocol == null) protocol = req.getScheme();
        incrementNamedCountingMonitor(protocolKey(protocol), this.protocolCounterMap);


    }
175391
public Set<EndpointHelper> determineEndpoints(Set<EndpointHelper> annotatedEndpointHelpers,
                                                  Set<EndpointHelper> programmaticEndpointHelpers,
                                                  Set<Class<? extends ServerApplicationConfig>> serverAppConfigs) {

        Set<Class<?>> annotatedEndpointClasses = new HashSet<Class<?>>();
        HashMap<Class<?>, EndpointHelper> endpointMap = new HashMap<Class<?>, EndpointHelper>();
        Set<EndpointHelper> returnHelpers = new HashSet<EndpointHelper>();

        Set<Class<? extends Endpoint>> programmaticEndpointClasses = new HashSet<Class<? extends Endpoint>>();
        Set<Class<? extends ServerEndpointConfig>> endpointConfigs = new HashSet<Class<? extends ServerEndpointConfig>>();

        // no ServerApplicationConfig objects, allow all the annotated endpoints through, but no programmatic endpoints
        if (serverAppConfigs.size() == 0) {
            return annotatedEndpointHelpers;
        }

        // first look at annotated Endpoints
        // build the set of annotated Endpoints to look through, also need a map of endpoints to helpers for later indexing
        for (EndpointHelper helper : annotatedEndpointHelpers) {
            Class<?> c = helper.getEndpointClass();
            annotatedEndpointClasses.add(c);
            // need a map of EndpointClass to EndpointHelper to index into later
            endpointMap.put(c, helper);
        }

        // if we have annotated endpoints, then pass the set of them to each user config object
        if (annotatedEndpointClasses.size() > 0) {
            for (Class<? extends ServerApplicationConfig> configClass : serverAppConfigs) {
                ServerApplicationConfig config = null;
                try {
                    config = configClass.newInstance();
                } catch (IllegalAccessException e) {
                    // allow instrumented FFDC to be used here
                } catch (InstantiationException e) {
                    // allow instrumented FFDC to be used here
                }

                if (config != null) {
                    // get from the user config object the configs for which endpoints to use
                    Set<Class<?>> annotatedEnpointsToUse = config.getAnnotatedEndpointClasses(annotatedEndpointClasses);

                    // for each returned endpoint class, find the endpoint helper and put it into the return set
                    for (Class<?> c : annotatedEnpointsToUse) {
                        EndpointHelper helper = endpointMap.get(c);
                        if (tc.isDebugEnabled()) {
                            Tr.debug(tc, "will use annoated endpoint of: " + c);
                        }
                        returnHelpers.add(helper);
                    }
                }
            }
        }

        // now do the same with programmatic configs.
        // first look at programmatic Endpoints
        // build the set of programmatic Endpoints to look through, also need a map of endpoints to helpers for later indexing
        endpointMap.clear();
        for (EndpointHelper helper : programmaticEndpointHelpers) {
            Class<?> c = helper.getEndpointClass();
            programmaticEndpointClasses.add((Class<? extends Endpoint>) c);
            // need a map of EndpointClass to EndpointHelper to index into later
            endpointMap.put(c, helper);
        }

        // if we have programmatic endpoints, then pass the set of them to each user config object
        if (programmaticEndpointClasses.size() > 0) {
            for (Class<? extends ServerApplicationConfig> configClass : serverAppConfigs) {
                ServerApplicationConfig config = null;
                try {
                    config = configClass.newInstance();
                } catch (IllegalAccessException e) {
                    // allow instrumented FFDC to be used here
                } catch (InstantiationException e) {
                    // allow instrumented FFDC to be used here
                }

                if (config != null) {
                    // get from the user config object which of the programmatic endpoints to use
                    Set<ServerEndpointConfig> programmaticEnpointConfigsToUse = config.getEndpointConfigs(programmaticEndpointClasses);
                    if (tc.isDebugEnabled()) {
                        Tr.debug(tc, "programmaticEnpointConfigsToUse: " + programmaticEnpointConfigsToUse);
                    }
                    if (programmaticEnpointConfigsToUse != null) {
                        // for each returned endpoint config class, create the endpoint helper and put it into the return set
                        for (ServerEndpointConfig endpointConfig : programmaticEnpointConfigsToUse) {

                            Class<?> endpoint = endpointConfig.getEndpointClass();
                            // Question: is this really how we should map the endpoint from the user config, to the endpoint we scanned earlier?
                            // You can map a single endpoint to multiple URIs/configurators, etc, so creating new here.
                            if (tc.isDebugEnabled()) {
                                Tr.debug(tc, "endpointConfig class: " + endpoint.getName());
                            }
                            EndpointHelper scannedHelper = endpointMap.get(endpoint);
                            if (scannedHelper != null) {
                                EndpointHelper newHelper = new EndpointHelper();
                                newHelper.setEndpointClass(scannedHelper.getEndpointClass());

                                newHelper.setServerEndpointConfig(endpointConfig);
                                if (tc.isDebugEnabled()) {
                                    Tr.debug(tc, "will use programmatic endpoint of: " + endpoint);
                                }
                                returnHelpers.add(newHelper);
                            }
                        }
                    }
                }
            }
        }

        return returnHelpers;
    }
602051
protected void fetchData() throws IOException {
    // if not connected to the collector, wait for a while then try connecting
    if (rpcCollector == null) {
      try {
        Thread.sleep(RECONNECT_PERIOD);
      } catch (InterruptedException e) {
        // do nothing
      }
      connect();
    }
    try {
      clusterUtil = rpcCollector.getClusterUtilization();
      for (JobUtilization job:
        rpcCollector.getAllRunningJobUtilization()) {
        allJobUtil.put(job.getJobId(), job);
      }
      for (TaskTrackerUtilization tt :
        rpcCollector.getAllTaskTrackerUtilization()) {
        allTaskTrackerUtil.put(tt.getHostName(), tt);
      }
    } catch (Exception e) {
        // When the Collector is down, clear the old data
        clusterUtil = null;
        allJobUtil.clear();
        allTaskTrackerUtil.clear();
        LOG.warn("Error obtaining data from Collector.");
    }
  }
354229
protected final PrcSeSellerDel<RS> lazyGetPrcSeSellerDel(final Map<String, Object> pAddParam) throws Exception {
    String beanName = PrcSeSellerDel.class.getSimpleName();
    @SuppressWarnings("unchecked")
    PrcSeSellerDel<RS> proc = (PrcSeSellerDel<RS>) this.processorsMap.get(beanName);
    if (proc == null) {
      proc = new PrcSeSellerDel<RS>();
      proc.setSrvOrm(getSrvOrm());
      proc.setFindSeSeller(getFindSeSeller());
      //assigning fully initialized object:
      this.processorsMap.put(beanName, proc);
      this.logger.info(null, FctBnTradeEntitiesProcessors.class, beanName + " has been created.");
    }
    return proc;
  }
776512
@Override
    public void collectMetrics() {
        long nanosBefore = System.nanoTime();
        /*
         * Optimisation tip: no need to skip 'mbeanServer.queryNames()' if the ObjectName is not a pattern
         * (i.e. not '*' or '?' wildcard) because the mbeanserver internally performs the check.
         * Seen on com.sun.jmx.interceptor.DefaultMBeanServerInterceptor
         */
        Set<ObjectName> matchingObjectNames = embeddedJmxTrans.getMbeanServer().queryNames(this.objectName, null);
        logger.trace("Query {} returned {}", objectName, matchingObjectNames);

        for (ObjectName matchingObjectName : matchingObjectNames) {
            long epochInMillis = System.currentTimeMillis();
            try {
                AttributeList jmxAttributes = embeddedJmxTrans.getMbeanServer().getAttributes(matchingObjectName, this.attributeNames);
                logger.trace("Query {} returned {}", matchingObjectName, jmxAttributes);
                for (Attribute jmxAttribute : jmxAttributes.asList()) {
                    QueryAttribute queryAttribute = this.attributesByName.get(jmxAttribute.getName());
                    Object value = jmxAttribute.getValue();
                    int count = queryAttribute.collectMetrics(matchingObjectName, value, epochInMillis, this.queryResults);
                    collectedMetricsCount.addAndGet(count);
                }
            } catch (Exception e) {
                logger.warn("Exception processing query {}", this, e);
            }
        }
        collectionCount.incrementAndGet();
        long nanosAfter = System.nanoTime();
        collectionDurationInNanos.addAndGet(nanosAfter - nanosBefore);
    }
317407
public void collectConsumerSubInfo(final ConsumerConfig consumerConfig) {

        try {
            Id consumerConfigId = rpcLookoutId.fetchConsumerSubId();
            Lookout.registry().info(consumerConfigId, new Info<ConsumerConfig>() {
                @Override
                public ConsumerConfig value() {
                    return consumerConfig;
                }
            });
        } catch (Throwable t) {
            LOGGER.error(LogCodes.getLog(LogCodes.ERROR_METRIC_REPORT_ERROR), t);
        }
    }
268740
private static void retrieveServerMetadata() throws Exception {
        if (get() == null) {
            throw new IllegalStateException("Cannot retrieve the server metadata - no reference to Chameleon stored " +
                    "in the holder");
        }

        int factor = Integer.getInteger("time.factor", 1);
        if (factor != 1) {
            TimeUtils.TIME_FACTOR = factor;
        }

        // Before checking, ensure stability.
        ServiceReference[] references = get().waitForStability().context().getAllServiceReferences(WisdomEngine.class
                .getName(), null);

        if (references == null || references.length == 0) {
            references = get().waitForStability().context().getAllServiceReferences(WisdomEngine.class.getName(), null);
        }

        if (references == null || references.length == 0) {
            throw new IllegalStateException("Cannot retrieve the Wisdom Engine service");
        }

        Object engine = get().context().getService(references[0]);
        HOST_NAME = (String) engine.getClass().getMethod("hostname").invoke(engine);
        HTTP_PORT = (int) engine.getClass().getMethod("httpPort").invoke(engine);
        HTTPS_PORT = (int) engine.getClass().getMethod("httpsPort").invoke(engine);
    }
1219034
def _rpc_metadata(self):
        
        if self._rpc_metadata_internal is None:
            self._rpc_metadata_internal = _helpers.metadata_with_prefix(
                self._database_string
            )

        return self._rpc_metadata_internal
606936
public java.util.List<ServerCertificateMetadata> getServerCertificateMetadataList() {
        if (serverCertificateMetadataList == null) {
            serverCertificateMetadataList = new com.amazonaws.internal.SdkInternalList<ServerCertificateMetadata>();
        }
        return serverCertificateMetadataList;
    }
726142
public final void setModel(PixelModel newModel) {
		if (newModel == null) throw new NullPointerException();
		
		if (model != newModel) {
			if (model != null)
				model.removeChangeListener(modelListener);
			model = newModel;
			model.addChangeListener(modelListener);
			update();
		}
	}
252102
protected void updateStats(Collection<Address> dests, boolean anycast, boolean sync, long time) {
        if(anycast)
            rpc_stats.addAnycast(sync, time, dests);
        else
            rpc_stats.add(RpcStats.Type.MULTICAST, null, sync, time);
    }
961961
public void initServer() {

        if (m_initialized) {
            return;
        }
        try {
            m_registry = LocateRegistry.createRegistry(m_port);
            m_provider = new CmsRemoteShellProvider(m_port);
            I_CmsRemoteShellProvider providerStub = (I_CmsRemoteShellProvider)(UnicastRemoteObject.exportObject(
                m_provider,
                m_port));
            m_registry.bind(CmsRemoteShellConstants.PROVIDER, providerStub);
            m_initialized = true;
        } catch (Exception e) {
            LOG.error(e.getLocalizedMessage(), e);
        }
    }
678997
@Override
  public final void handleModelChanged(final ReplicationAccMethod pModel) {
    if (this.replicationMethod != null
      && this.replicationMethod.getItsId().equals(pModel.getItsId())) {
      this.replicationMethod = null;
    }
  }
769787
private static void awaitServerInitialization(JvmAgentConfig pConfig, final Instrumentation instrumentation) {
        List<ServerDetector> detectors = MBeanServerHandler.lookupDetectors();
        for (ServerDetector detector : detectors) {
            detector.jvmAgentStartup(instrumentation);
        }
    }