This bind method will be called when {@link MetricManagementService} is registered.

@param metricManagementService The {@link MetricManagementService} instance registered as an OSGi service
772105
@Reference(
            name = "carbon.metrics.management.service",
            service = MetricManagementService.class,
            cardinality = ReferenceCardinality.MANDATORY,
            policy = ReferencePolicy.DYNAMIC,
            unbind = "unsetMetricManagementService"
    )
    protected void setMetricManagementService(MetricManagementService metricManagementService) {
        DataHolder.getInstance().setMetricManagementService(metricManagementService);
    }
1126183
private boolean registerMetricDescriptor(
      io.opencensus.metrics.export.MetricDescriptor metricDescriptor) {
    String metricName = metricDescriptor.getName();
    io.opencensus.metrics.export.MetricDescriptor existingMetricDescriptor =
        registeredMetricDescriptors.get(metricName);
    if (existingMetricDescriptor != null) {
      if (existingMetricDescriptor.equals(metricDescriptor)) {
        // Ignore metricDescriptor that are already registered.
        return true;
      } else {
        logger.log(
            Level.WARNING,
            "A different metric with the same name is already registered: "
                + existingMetricDescriptor);
        return false;
      }
    }
    registeredMetricDescriptors.put(metricName, metricDescriptor);
    if (isBuiltInMetric(metricName)) {
      return true; // skip creating metric descriptor for stackdriver built-in metrics.
    }

    Span span = tracer.getCurrentSpan();
    span.addAnnotation("Create Stackdriver Metric.");
    MetricDescriptor stackDriverMetricDescriptor =
        StackdriverExportUtils.createMetricDescriptor(
            metricDescriptor, projectId, domain, displayNamePrefix, constantLabels);

    CreateMetricDescriptorRequest request =
        CreateMetricDescriptorRequest.newBuilder()
            .setName(projectName.toString())
            .setMetricDescriptor(stackDriverMetricDescriptor)
            .build();
    try {
      metricServiceClient.createMetricDescriptor(request);
      span.addAnnotation("Finish creating MetricDescriptor.");
      return true;
    } catch (ApiException e) {
      logger.log(Level.WARNING, "ApiException thrown when creating MetricDescriptor.", e);
      span.setStatus(
          Status.CanonicalCode.valueOf(e.getStatusCode().getCode().name())
              .toStatus()
              .withDescription(
                  "ApiException thrown when creating MetricDescriptor: "
                      + StackdriverExportUtils.exceptionMessage(e)));
      return false;
    } catch (Throwable e) {
      logger.log(Level.WARNING, "Exception thrown when creating MetricDescriptor.", e);
      span.setStatus(
          Status.UNKNOWN.withDescription(
              "Exception thrown when creating MetricDescriptor: "
                  + StackdriverExportUtils.exceptionMessage(e)));
      return false;
    }
  }
947829
public void registerHandler(HttpServiceBindingDescriptor serviceBindingDescriptor) {
        for (ProtocolBinding protocolBinding : protocolBindingRegistry.getProtocolBindings()) {
            if (protocolBinding.getProtocol() == serviceBindingDescriptor.getServiceProtocol()) {
                String contextPath = protocolBinding.getContextRoot() + serviceBindingDescriptor.getServiceContextPath();

                JettyHandlerSpecification handlerSpec = handlerSpecificationMap.get(contextPath);
                if (handlerSpec == null) {
                    handlerSpec = new JettyHandlerSpecification(protocolBinding.getContextRoot(),
                            protocolBinding.getProtocol(), serviceBindingDescriptor.getServiceContextPath());
                    handlerSpecificationMap.put(contextPath, handlerSpec);
                }
                if (protocolBinding.getIdentityTokenResolver() != null) {
                    handlerSpec.addServiceVersionToTokenResolverEntry(serviceBindingDescriptor.getServiceVersion(), protocolBinding.getIdentityTokenResolver());
                }
            }
        }
        commandProcessorFactory.getCommandProcessor(serviceBindingDescriptor.getServiceProtocol()).bind(serviceBindingDescriptor);
    }
1337342
public void setMetric(String metric) {
        SystemAssert.requireArgument(metric != null && !metric.isEmpty(), "Metric cannot be null or empty.");
        this.metric = metric;
    }
836608
private boolean register(String name, Metric metric)
    { 
        boolean ret = allColumnFamilyMetrics.putIfAbsent(name,  new HashSet<Metric>()) == null;
        allColumnFamilyMetrics.get(name).add(metric);
        all.add(name);
        return ret;
    }
519138
public void start() throws Exception {
        Exceptions.checkNotClosed(this.closed, this);

        log.info("Initializing metrics provider ...");
        MetricsProvider.initialize(builderConfig.getConfig(MetricsConfig::builder));
        statsProvider = MetricsProvider.getMetricsProvider();
        statsProvider.start();

        log.info("Initializing ZooKeeper Client ...");
        this.zkClient = createZKClient();

        log.info("Initializing Service Builder ...");
        this.serviceBuilder.initialize();

        log.info("Creating StreamSegmentService ...");
        StreamSegmentStore service = this.serviceBuilder.createStreamSegmentService();

        log.info("Creating TableStoreService ...");
        TableStore tableStoreService = this.serviceBuilder.createTableStoreService();

        log.info("Creating Segment Stats recorder ...");
        autoScaleMonitor = new AutoScaleMonitor(service, builderConfig.getConfig(AutoScalerConfig::builder));

        TokenVerifierImpl tokenVerifier = new TokenVerifierImpl(builderConfig.getConfig(AutoScalerConfig::builder));

        // Log the configuration
        log.info(serviceConfig.toString());
        log.info(builderConfig.getConfig(AutoScalerConfig::builder).toString());

        this.listener = new PravegaConnectionListener(this.serviceConfig.isEnableTls(), this.serviceConfig.getListeningIPAddress(),
                                                      this.serviceConfig.getListeningPort(), service, tableStoreService,
                                                      autoScaleMonitor.getStatsRecorder(), autoScaleMonitor.getTableSegmentStatsRecorder(),
                                                      tokenVerifier, this.serviceConfig.getCertFile(), this.serviceConfig.getKeyFile(),
                                                      this.serviceConfig.isReplyWithStackTraceOnError());

        this.listener.startListening();
        log.info("PravegaConnectionListener started successfully.");
        log.info("StreamSegmentService started.");
    }
705433
public void setMetricDataResults(java.util.Collection<MetricDataResult> metricDataResults) {
        if (metricDataResults == null) {
            this.metricDataResults = null;
            return;
        }

        this.metricDataResults = new com.amazonaws.internal.SdkInternalList<MetricDataResult>(metricDataResults);
    }
1160428
public void registerService(ProvidedServiceInstance serviceInstance,
            OperationalStatus status) {

        serviceInstance.setStatus(status);
        registerService(serviceInstance);
    }
701164
public void register() {
        LOGGER.debug("Register mount tracker as OSGi service");

        synchronized (this) {
            if (serviceRegistration != null) {
                throw new IllegalStateException(String.format("%s [%s] had been already registered.", getClass()
                    .getSimpleName(), this));
            }
            serviceRegistration = bundleContext.registerService(SERVICE_CLASSES, this, properties);
        }
    }
701822
public void registerMetrics(MetricRegistry metricRegistry, String pipelineId) {
        meterName = name(Pipeline.class, pipelineId, "stage", String.valueOf(stage()), "executed");
        executed = metricRegistry.meter(meterName);
    }
44029
protected RegisteredService getRegisteredServiceForConsent(final RequestContext requestContext, final Service service) {
        val serviceToUse = this.authenticationRequestServiceSelectionStrategies.resolveService(service);
        val registeredService = this.servicesManager.findServiceBy(serviceToUse);
        RegisteredServiceAccessStrategyUtils.ensureServiceAccessIsAllowed(service, registeredService);
        return registeredService;
    }
907671
synchronized public void performHostDiscovery(MetricRegistry metricRegistry) {
        // Host discovery is not idempotent; only take action if it hasn't been performed.
        if (_hostDiscoveryPerformed) {
            return;
        }

        Iterable<String> hosts = null;

        // Statically configured list of seeds.
        if (_seeds != null) {
            hosts = Splitter.on(',').trimResults().split(_seeds);
        }

        // Perform ZooKeeper discovery to find the seeds.
        if (_zooKeeperServiceName != null) {
            checkState(hosts == null, "Too many host discovery mechanisms configured.");
            checkState(_curator != null,
                    "ZooKeeper host discovery is configured but withZooKeeperHostDiscovery() was not called.");

            try (HostDiscovery hostDiscovery = new ZooKeeperHostDiscovery(_curator, _zooKeeperServiceName, metricRegistry)) {
                List<String> hostList = Lists.newArrayList();
                for (ServiceEndPoint endPoint : hostDiscovery.getHosts()) {
                    // The host:port is in the end point ID
                    hostList.add(endPoint.getId());

                    // The partitioner class name is in the json-encoded end point payload
                    if (_partitioner == null && endPoint.getPayload() != null) {
                        JsonNode payload = JsonHelper.fromJson(endPoint.getPayload(), JsonNode.class);
                        String partitioner = payload.path("partitioner").textValue();
                        if (partitioner != null) {
                            _partitioner = CassandraPartitioner.fromClass(partitioner);
                        }
                    }
                }
                hosts = hostList;
            } catch (IOException ex) {
                // suppress any IOExceptions that might result from closing our ZooKeeperHostDiscovery
            }
        }

        checkState(hosts != null, "No Cassandra host discovery mechanisms are configured.");
        //noinspection ConstantConditions
        checkState(!Iterables.isEmpty(hosts), "Unable to discover any Cassandra seed instances.");
        checkState(_partitioner != null, "Cassandra partitioner not configured or discoverable.");
        _seeds = Joiner.on(',').join(hosts);
        _hostDiscoveryPerformed = true;
    }
602489
public static void register(MetricsRegistry metricsRegistry) {
        checkNotNull(metricsRegistry, "metricsRegistry");

        ThreadMXBean mxBean = ManagementFactory.getThreadMXBean();
        metricsRegistry.register(mxBean, "thread.threadCount", MANDATORY, ThreadMXBean::getThreadCount);
        metricsRegistry.register(mxBean, "thread.peakThreadCount", MANDATORY, ThreadMXBean::getPeakThreadCount);
        metricsRegistry.register(mxBean, "thread.daemonThreadCount", MANDATORY, ThreadMXBean::getDaemonThreadCount);
        metricsRegistry.register(mxBean, "thread.totalStartedThreadCount", MANDATORY, ThreadMXBean::getTotalStartedThreadCount);
    }
1187315
public void bindService() {
        Log.v(TAG, "Trying to bind the service");
        Context context = this.context.get();
        isBound = false;
        if (context != null && preferredPackage != null) {
            isBound = CustomTabsClient.bindCustomTabsService(context, preferredPackage, this);
        }
        Log.v(TAG, "Bind request result: " + isBound);
    }
811856
public void add(Metric m) {
        final MetricName key = m.getName();
        metrics_.put(key, m);
    }
883567
public void submitMetrics(MetricsRecord metricsRecord) {
    List<PoolMetadata> poolMetadatas = getPoolMetadataList();
    PoolFairnessCalculator.calculateFairness(poolMetadatas, metricsRecord);
    for (SchedulerForType scheduler: schedulersForTypes.values()) {
      scheduler.submitMetrics();
    }
  }
1033040
@Override
	public void bind(ServiceBindingDescriptor bindingDescriptor) {
        String servicePlusMajorVersion=bindingDescriptor.getServiceName() +
                "-v" + bindingDescriptor.getServiceVersion().getMajor();

        if (serviceBindingDescriptors.containsKey(servicePlusMajorVersion)) {
                throw new PanicInTheCougar("More than one version of service [" + bindingDescriptor.getServiceName() +
                        "] is attempting to be bound for the same major version. The clashing versions are [" +
                        serviceBindingDescriptors.get(servicePlusMajorVersion).getServiceVersion() + ", " +
                        bindingDescriptor.getServiceVersion() +
                        "] - only one instance of a service is permissable for each major version");
        }
		serviceBindingDescriptors.put(servicePlusMajorVersion, bindingDescriptor);
	}