Initialize callstats.

@param appId the app id
@param appSecret the app secret
@param bridgeId the bridge id
@param serverInfo the server info
@param callStatsInitListener the call stats init listener
504702
public void initialize(final int appId, final String appSecret, final String bridgeId,
      final ServerInfo serverInfo, final CallStatsInitListener callStatsInitListener) {
    if (StringUtils.isBlank(appSecret)) {
      logger.error("intialize: Arguments cannot be null ");
      throw new IllegalArgumentException("intialize: Arguments cannot be null");
    }
    initialize(appId, new TokenGeneratorHs256(appSecret.toCharArray(), appId, bridgeId), bridgeId,
        serverInfo, callStatsInitListener);
  }
1347380
public ClientResponseImpl call(Object... paramListIn) {
        m_perCallStats = m_statsCollector.beginProcedure();

        // if we're keeping track, calculate parameter size
        if (m_perCallStats != null) {
            StoredProcedureInvocation invoc = (m_txnState != null ? m_txnState.getInvocation() : null);
            ParameterSet params = (invoc != null ? invoc.getParams() : ParameterSet.fromArrayNoCopy(paramListIn));
            m_perCallStats.setParameterSize(params.getSerializedSize());
        }

        ClientResponseImpl result = coreCall(paramListIn);

        // if we're keeping track, calculate result size
        if (m_perCallStats != null) {
            m_perCallStats.setResultSize(result.getResults());
        }

        m_statsCollector.endProcedure(result.getStatus() == ClientResponse.USER_ABORT,
                                      (result.getStatus() != ClientResponse.USER_ABORT) &&
                                      (result.getStatus() != ClientResponse.SUCCESS),
                                      m_perCallStats);
        // allow the GC to collect per-call stats if this proc isn't called for a while
        m_perCallStats = null;

        return result;
    }
1140310
@CommandArgument
  public void stat(int index) {
    if (reconnectCountdown > 0) {
      System.out.printf("Lost connection, reconnecting in %d seconds.\n", reconnectCountdown);
      return;
    }
    if (reconnectCountdown == 0) {
      System.out.println("Connecting...");
      return;
    }
    if (taskProgressStates == null) {
      System.out.println("Worker not running");
      return;
    }
    Iterator<ProgressState> iter = taskProgressStates.iterator();
    while (iter.hasNext()) {
      ProgressState state = iter.next();
      if (state.isCancelled() || state.isComplete()) {
        iter.remove();
      }
    }
    if (index == 0) { // print status of all workers.
      List<ProgressState> taskProgressStates = new ArrayList<ProgressState>(this.taskProgressStates);
      if (taskProgressStates != null) {
        System.out.println("  # Progress                         Status                             ");
        System.out.println("------------------------------------------------------------------------");
        for (int i = 0, n = taskProgressStates.size(); i < n; i++) {
          ProgressState state = taskProgressStates.get(i);
          char flag = ' ';
          if (state.isComplete()) {
            flag = '*';
          } else if (state.isCancelled()) {
            flag = 'X';
          } else if (state.isCancelPending()) {
            flag = 'C';
          }
          String status = state.getStatus();
          if (status.length() > 35) {
            status = status.substring(0, 34) + ">";
          }
          boolean indeterminant = state.isIndeterminant();
          double progress = state.getProgress();
          String progressBar;
          if (!indeterminant) {
            StringBuilder progressBarBuilder = new StringBuilder("|");
            for (int j = 0; j < 25; j++) {
              if (indeterminant) {
              }
              progressBarBuilder.append((progress >= (double) (j + 1) / 25.0) ? "=" : " ");
            }
            progressBarBuilder.append("|");
            progressBar = progressBarBuilder.toString();
          } else {
            progressBar = "|?????????????????????????|";
          }
          String progStr = (indeterminant ? "????" : String.format("% 3.0f%%", 100.0 * progress));
          System.out.printf("%c% 2d %s %s %-35s\n",
              flag, i + 1, progressBar, progStr, status);
        }
      }
    } else if (index > 0 && index <= this.taskProgressStates.size()) {
      // print status of a single worker.
      ProgressState state = this.taskProgressStates.get(index - 1);
      System.out.printf("Worker #%d", index);
      if (state.isComplete()) {
        System.out.print(" [COMPLETE]");
      } else if (state.isCancelled()) {
        System.out.print(" [CANCELLED]");
      } else if (state.isCancelPending()) {
        System.out.print(" [CANCEL PENDING]");
      }
      System.out.println();
      if (state.isIndeterminant()) {
        System.out.print("Progress : ???");
      } else {
        System.out.printf("Progress : %.2f%%", 100.0 * state.getProgress());
      }
      int maximum = state.getMaximum();
      int value = state.getValue();
      if (maximum > 0) {
        System.out.printf(" (%d/%d)", value, maximum);
      }
      System.out.println();
      System.out.printf("Status   : %s\n", state.getStatus());
    } else {
      System.err.println("Invalid worker number");
    }

  }
1131314
public void statsReset()
    {
        _statsStartedAt=System.currentTimeMillis();

        _connections=0;
        
        _connectionsOpenMin=_connectionsOpen;
        _connectionsOpenMax=_connectionsOpen;
        _connectionsOpen=0;
        
        _connectionsDurationMin=0;
        _connectionsDurationMax=0;
        _connectionsDurationTotal=0;

        _errors=0;
        _requests=0;

        _requestsActiveMin=_requestsActive;
        _requestsActiveMax=_requestsActive;
        _requestsActive=0;
        
        _connectionsRequestsMin=0;
        _connectionsRequestsMax=0;

        _requestsDurationMin=0;
        _requestsDurationMax=0;
        _requestsDurationTotal=0;
    }
693675
void initializeClientUnprotected(String host, int port, String sessionId)
    throws IOException {
    if (client != null) {
      return;
    }
    LOG.info("Creating JT client to " + host + ":" + port);
    long connectTimeout = RemoteJTProxy.getRemotJTTimeout(conf);
    int rpcTimeout = RemoteJTProxy.getRemoteJTRPCTimeout(conf);
    remoteJTAddr = new InetSocketAddress(host, port);
    client = RPC.waitForProtocolProxy(
      JobSubmissionProtocol.class,
      JobSubmissionProtocol.versionID,
      remoteJTAddr,
      conf,
      connectTimeout,
      rpcTimeout
      ).getProxy();
    remoteJTStatus = RemoteJTStatus.SUCCESS;
    remoteJTHost = host;
    remoteJTPort = port;
    remoteSessionId = sessionId;
    
    if (remoteJTState != null) {
      remoteJTState.setSessionId(sessionId);
    }
  }
903372
protected void notifyInit () {
		final String sourceMethod = "notifyInit"; //$NON-NLS-1$
		IServiceReference[] refs = null;
		try {
			if(_aggregator != null && _aggregator.getPlatformServices() != null){
				refs = _aggregator.getPlatformServices().getServiceReferences(ICacheManagerListener.class.getName(),"(name=" + _aggregator.getName() + ")");	//$NON-NLS-1$ //$NON-NLS-2$
				if (refs != null) {
					for (IServiceReference ref : refs) {
						ICacheManagerListener listener = (ICacheManagerListener)_aggregator.getPlatformServices().getService(ref);
						if (listener != null) {
							try {
								listener.initialized(this);
							} catch (Throwable t) {
								if (log.isLoggable(Level.WARNING)) {
									log.logp(Level.WARNING, CacheManagerImpl.class.getName(), sourceMethod, t.getMessage(), t);
								}
							} finally {
								_aggregator.getPlatformServices().ungetService(ref);
							}
						}
					}
				}
			}
		} catch (PlatformServicesException e) {
			if (log.isLoggable(Level.SEVERE)) {
				log.log(Level.SEVERE, e.getMessage(), e);
			}
		}
	}
796947
@Override
    public /*final*/ void bind(ResourceAddress address, IoHandler handler, BridgeSessionInitializer<? extends IoFuture> initializer) {

        // bind only address with matching scheme
        URI location = address.getResource();
        String schemeName = location.getScheme();
        if (!canBind(schemeName)) {
            throw new IllegalArgumentException(format("Unexpected scheme \"%s\" for URI: %s", schemeName, location));
        }
        
        if (!started.get()) {
            synchronized (started) {
                if (!started.get()) {
                    init();
                    started.set(true);
                }
            }
        }

        boolean bindAlternate;
        do {
            bindAlternate = address.getOption(BIND_ALTERNATE);
            //
            // add binding, expecting no clashing (according to BINDINGS_COMPARATOR)
            //
            Binding newBinding = new Binding(address, handler, initializer);
            Binding oldBinding = bindings.addBinding(newBinding);

            //System.out.println(getClass().getSimpleName()+"@"+hashCode()+" binding: "+address.getExternalURI()+" -- "+address.getOption(NEXT_PROTOCOL));

            if (oldBinding != null) {
                throw new RuntimeException("Unable to bind address " + address
                        + " because it collides with an already bound address " + oldBinding.bindAddress());
            }

            bindInternal(address, handler, initializer);
            address = address.getOption(ALTERNATE);
            
        } while (address != null && bindAlternate);
    }
131144
function init(endPoint, accessKeyId, accessKeySecret, securityToken = null, project) {
  return AliyunLog && AliyunLog.initAliyunLog && AliyunLog.initAliyunLog(endPoint, accessKeyId, accessKeySecret, securityToken, project);
}
901454
@Override
    public void init(String webAppRfsPath, String servletMapping, String defaultWebApplication) {

        try {
            super.init(webAppRfsPath, servletMapping, defaultWebApplication);
            CmsUpdateInfo.INSTANCE.setAdeModuleVersion(getInstalledModules().get("org.opencms.ade.containerpage"));

            if (m_workplaceUpdateThread != null) {
                if (m_workplaceUpdateThread.isAlive()) {
                    m_workplaceUpdateThread.kill();
                }
                m_workplaceUpdateThread = null;
            }
            if (m_dbUpdateThread != null) {
                if (m_dbUpdateThread.isAlive()) {
                    m_dbUpdateThread.kill();
                }
                m_dbUpdateThread = null;
                m_newLoggingOffset = 0;
                m_oldLoggingOffset = 0;
            }
        } catch (Exception e) {
            e.printStackTrace();
            throw new RuntimeException(e);
        }
    }
433838
private void setData(BridgeStatusInfo bridgeStatusInfo) {
    setCpuUsage(bridgeStatusInfo.getCpuUsage());
    setMemoryUsage(bridgeStatusInfo.getMemoryUsage());
    threadCount = bridgeStatusInfo.getThreadCount();
    totalMemory = bridgeStatusInfo.getTotalMemory();

    intervalAverageJitter = bridgeStatusInfo.getAvgIntervalJitter();
    intervalAverageRtt = bridgeStatusInfo.getAvgIntervalRtt();
    totalRtpLostPackets = (long) bridgeStatusInfo.getTotalLoss();
    audioFabricCount = bridgeStatusInfo.getAudioFabricCount();
    videoFabricCount = bridgeStatusInfo.getVideoFabricCount();
    conferenceCount = bridgeStatusInfo.getConferenceCount();
    intervalDownloadBitrate = bridgeStatusInfo.getIntervalDownloadBitRate();
    intervalUploadBitrate = bridgeStatusInfo.getIntervalUploadBitRate();
    participantsCount = bridgeStatusInfo.getParticipantsCount();
    intervalReceivedBytes = bridgeStatusInfo.getIntervalReceivedBytes();
    intervalSentBytes = bridgeStatusInfo.getIntervalSentBytes();
    intervalRtpFractionLoss = bridgeStatusInfo.getIntervalRtpFractionLoss();
  }
401947
public static Map<String, Object> getAppstatsDataFor(String appstatsId, Integer maxStackFrames)
  {
    Map<String, Object> appstatsMap = null;
    MemcacheWriter writer = new MemcacheWriter(null, MemcacheServiceFactory.getMemcacheService("__appstats__"));
    StatsProtos.RequestStatProto appstats;
    try
    {
      appstats = writer.getFull(Long.parseLong(appstatsId));
    } catch (NumberFormatException e)
    {
      return appstatsMap;
    }
    if (appstats != null)
    {
      appstatsMap = new HashMap<String, Object>();
      appstatsMap.put("totalTime", appstats.getDurationMilliseconds());

      Map<String, Map<String, Object>> rpcInfoMap = new LinkedHashMap<String, Map<String, Object>>();
      for (AggregateRpcStatsProto rpcStat : appstats.getRpcStatsList())
      {
        Map<String, Object> rpcInfo = rpcInfoMap.get(rpcStat.getServiceCallName());
        if (rpcInfo == null)
        {
          rpcInfo = new LinkedHashMap<String, Object>();
          rpcInfoMap.put(rpcStat.getServiceCallName(), rpcInfo);
        }

        rpcInfo.put("totalCalls", rpcStat.getTotalAmountOfCalls());
        rpcInfo.put("totalTime", Long.valueOf(0));
      }

      List<Map<String, Object>> callInfoMap = new ArrayList<Map<String, Object>>();
      for (IndividualRpcStatsProto rpcStat : appstats.getIndividualStatsList())
      {
        // Update the total time for the RPC method
        Map<String, Object> rpcInfo = rpcInfoMap.get(rpcStat.getServiceCallName());
        rpcInfo.put("totalTime", ((Long) rpcInfo.get("totalTime")) + rpcStat.getDurationMilliseconds());

        // Get info about this specific call
        Map<String, Object> callInfo = new LinkedHashMap<String, Object>();
        callInfoMap.add(callInfo);
        callInfo.put("serviceCallName", rpcStat.getServiceCallName());
        callInfo.put("totalTime", rpcStat.getDurationMilliseconds());
        callInfo.put("startOffset", rpcStat.getStartOffsetMilliseconds());
        callInfo.put("request", truncate(rpcStat.getRequestDataSummary(), 100));
        callInfo.put("response", truncate(rpcStat.getResponseDataSummary(), 100));
        // Get the stack trace
        List<String> callStack = new ArrayList<String>();
        int i = 0;
        for (StackFrameProto frame : rpcStat.getCallStackList())
        {
          if (maxStackFrames != null && i == maxStackFrames)
          {
            break;
          }
          callStack.add(String.format("%s.%s:%d", frame.getClassOrFileName(), frame.getFunctionName(), frame.getLineNumber()));
          i++;
        }
        callInfo.put("callStack", callStack);
      }
      appstatsMap.put("rpcStats", !rpcInfoMap.isEmpty() ? rpcInfoMap : null);
      appstatsMap.put("rpcCalls", !callInfoMap.isEmpty() ? callInfoMap : null);
    }
    return appstatsMap;
  }
348105
@Override
    public void init() throws ChannelException {
        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) {
            Tr.entry(tc, "init");
        }

        // Prevent duplicate initialization.
        if (this.isInitialized) {
            if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) {
                Tr.exit(tc, "init");
            }
            return;
        }

        // Extract the channel properties.
        try {
            Properties channelProps = getConfig().getProperties();
            // Handle a potentially null property map.
            if (channelProps != null) {
                this.alias = channelProps.getProperty(SSLChannelData.ALIAS_KEY);
                if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
                    if (this.alias != null) {
                        Tr.debug(tc, "Found alias in SSL properties, " + this.alias);
                    } else {
                        Tr.debug(tc, "No alias found in SSL properties");
                    }
                }
                //PI52696 - Timeout value for which the SSL closing handshake loop will attempt to complete final handshake
                //write before giving up.
                String timeoutValueInSSLClosingHandshake = channelProps.getProperty(SSLChannelConstants.TIMEOUT_VALUE_IN_SSL_CLOSING_HANDSHAKE);
                if (timeoutValueInSSLClosingHandshake != null) {
                    this.timeoutValueInSSLClosingHandshake = Integer.parseInt(timeoutValueInSSLClosingHandshake);
                    if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
                        Tr.debug(tc, "Found timeoutValueInSSLClosingHandshake in SSL properties, " + this.timeoutValueInSSLClosingHandshake);
                    }

                }

                //Check for system property so all SSL Channels can have the property enabled

                //APAR PI70332 - Add Java custom property to allow this property to be set on all inbound/outbound channels
                //without need of SSL configuration.

                String timeoutValueSystemProperty = AccessController.doPrivileged(new java.security.PrivilegedAction<String>() {
                    @Override
                    public String run() {
                        return (System.getProperty(SSLChannelConstants.TIMEOUT_VALUE_IN_SSL_CLOSING_HANDSHAKE));
                    }
                });

                if (timeoutValueSystemProperty != null) {
                    this.timeoutValueInSSLClosingHandshake = Integer.parseInt(timeoutValueSystemProperty);
                    if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
                        Tr.debug(tc, "Found timeoutValueInSSLClosingHandshake in SSL system properties, " + this.timeoutValueInSSLClosingHandshake);
                    }
                }

                String protocolVersion = channelProps.getProperty(SSLChannelConstants.PROPNAME_PROTOCOL_VERSION);
                if (protocolVersion != null) {

                    if (SSLChannelConstants.PROTOCOL_VERSION_11.equalsIgnoreCase(protocolVersion)) {
                        this.useH2ProtocolAttribute = Boolean.FALSE;
                    } else if (SSLChannelConstants.PROTOCOL_VERSION_2.equalsIgnoreCase(protocolVersion)) {
                        this.useH2ProtocolAttribute = Boolean.TRUE;
                    }

                    if ((TraceComponent.isAnyTracingEnabled()) && (tc.isEventEnabled()) && useH2ProtocolAttribute != null) {
                        Tr.event(tc, "SSL Channel Config: versionProtocolOption has been set to " + protocolVersion.toLowerCase(Locale.ENGLISH));
                    }
                }

            }
        } catch (Exception e) {
            // no FFDC required
            if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
                Tr.debug(tc, "init received exception handling properties; " + e);
            }
            throw new ChannelException(e);
        }

        if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
            Tr.debug(tc, "jsseProvider=" + this.jsseProvider);
        }

        // Indicate that initialization is complete.
        this.isInitialized = true;

        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) {
            Tr.exit(tc, "init");
        }
    }
466393
public static InvocationStat getInvocationStat(InvocationStatDimension statDimension) {
        InvocationStat invocationStat = ALL_STATS.get(statDimension);
        if (invocationStat == null) {
            invocationStat = new ServiceExceptionInvocationStat(statDimension);
            InvocationStat old = ALL_STATS.putIfAbsent(statDimension, invocationStat);
            if (old != null) {
                invocationStat = old;
            }
            for (InvocationStatListener listener : LISTENERS) {
                listener.onAddInvocationStat(invocationStat);
            }
        }
        return invocationStat;
    }
1134905
@Override
    protected void onMethodEntry() {
        if (enabledListeners.isEmpty())
            return;

        String probeKey = createKey();
        ProbeImpl probe = getProbe(probeKey);
        long probeId = probe.getIdentifier();

        setProbeInProgress(true);
        visitLdcInsn(Long.valueOf(probeId)); // long1 long2
        if (isStatic() || isConstructor()) {
            visitInsn(ACONST_NULL); // long1 long2 this
        } else {
            visitVarInsn(ALOAD, 0); // long1 long2 this
        }
        visitInsn(ACONST_NULL); // long1 long2 this that
        createParameterArray(); // long1 long2 this that args
        visitFireProbeInvocation();
        setProbeInProgress(false);

        setProbeListeners(probe, enabledListeners);
    }
676118
@Override
    public void init(VoidConfiguration voidConfiguration, Clipboard clipboard, NodeRole role, String localIp,
                    int localPort, short shardIndex) {
        //Runtime.getRuntime().addShutdownHook(new Thread(() -> shutdownSilent()));
    }
463764
public static synchronized void init(String[] args, String... extraArgs) {
		AppStarter.startUp(args, extraArgs);

		status = AppStatus.INITIALIZING;

		// no implicit classpath scanning here
		boot();
	}
237875
void setCallerId(final CallerId callerId)
    {
        final CallerId oldCallerId = this.callerId;

        this.callerId = callerId;
        firePropertyChange(PROPERTY_CALLER_ID, oldCallerId, callerId);
    }