This method increments the counter of failed Stream truncate operations in the system as well as the failed
truncate attempts for this specific Stream.

@param scope         Scope.
@param streamName    Name of the Stream.
357439
public void truncateStreamFailed(String scope, String streamName) {
        DYNAMIC_LOGGER.incCounterValue(globalMetricName(TRUNCATE_STREAM_FAILED), 1);
        DYNAMIC_LOGGER.incCounterValue(TRUNCATE_STREAM_FAILED, 1, streamTags(scope, streamName));
    }
113031
public void close(ScopeWrapper<S> scope)
      throws IOException {
    List<Throwable> exceptionsList = Lists.newArrayList();
    List<Service> awaitShutdown = Lists.newArrayList();

    for (Map.Entry<RawJobBrokerKey, Object> entry : Maps.filterKeys(this.sharedResourceCache.asMap(),
        new ScopeIsAncestorFilter(scope)).entrySet()) {

      this.sharedResourceCache.invalidate(entry.getKey());

      if (entry.getValue() instanceof ResourceInstance) {
        Object obj = ((ResourceInstance) entry.getValue()).getResource();
        // Catch unchecked exception while closing resources, make sure all resources managed by cache are closed.
        try {
          SharedResourcesBrokerUtils.shutdownObject(obj, log);
        } catch (Throwable t) {
          exceptionsList.add(t);
        }
        if (obj instanceof Service) {
          awaitShutdown.add((Service) obj);
        }
      }
    }

    for (Service service : awaitShutdown) {
      try {
        service.awaitTerminated(10, TimeUnit.SECONDS);
      } catch (TimeoutException te) {
        log.error("Failed to shutdown {}.", service);
      }
    }

    // log exceptions while closing resources up.
    if (exceptionsList.size() > 0) {
      log.error(exceptionsList.stream()
          .map(Throwables::getStackTraceAsString).collect(Collectors.joining("\n")));
    }
  }
595341
@Override
    @Synchronized
    public CompletableFuture<Map<String, StreamConfiguration>> listStreamsInScope(final String scopeName) {
        InMemoryScope inMemoryScope = scopes.get(scopeName);
        if (inMemoryScope != null) {
            return inMemoryScope.listStreamsInScope()
                    .thenApply(streams -> {
                        HashMap<String, StreamConfiguration> result = new HashMap<>();
                        for (String stream : streams) {
                            StreamConfiguration configuration = Futures.exceptionallyExpecting(
                                    getConfiguration(scopeName, stream, null, executor),
                                    e -> e instanceof StoreException.DataNotFoundException, null).join();
                            if (configuration != null) {
                                result.put(stream, configuration);
                            }
                        }
                        return result;
                    });
        } else {
            return Futures.failedFuture(StoreException.create(StoreException.Type.DATA_NOT_FOUND, scopeName));
        }
    }
292596
public static void reportActiveSegments(String scope, String streamName, int numSegments) {
        DYNAMIC_LOGGER.reportGaugeValue(SEGMENTS_COUNT, numSegments, streamTags(scope, streamName));
    }
430397
public static void incr(String counterName) {
    org.apache.heron.api.metric.GlobalMetrics.incr(counterName);
  }
1340005
@Override
    public void mark(int readlimit) {
        abortIfNeeded();
        if ( !isAtStart )
            throw new UnsupportedOperationException("Chunk-encoded stream only supports mark() at the start of the stream.");
        if (is.markSupported()) {
            if (log.isDebugEnabled()) {
                log.debug("AwsChunkedEncodingInputStream marked at the start of the stream "
                        + "(will directly mark the wrapped stream since it's mark-supported).");
            }
            is.mark(readlimit);
        }
        else {
            if (log.isDebugEnabled()) {
                log.debug("AwsChunkedEncodingInputStream marked at the start of the stream "
                        + "(initializing the buffer since the wrapped stream is not mark-supported).");
            }
            decodedStreamBuffer = new DecodedStreamBuffer(maxBufferSize);
        }
    }
7578
public CompletableFuture<CreateScopeStatus> createScope(final String scope) {
        Exceptions.checkNotNullOrEmpty(scope, "scope");
        try {
            NameUtils.validateScopeName(scope);
        } catch (IllegalArgumentException | NullPointerException e) {
            log.warn("Create scope failed due to invalid scope name {}", scope);
            return CompletableFuture.completedFuture(CreateScopeStatus.newBuilder().setStatus(
                    CreateScopeStatus.Status.INVALID_SCOPE_NAME).build());
        }
        return streamStore.createScope(scope);
    }
766788
private void loadMoreScoped(WstxInputSource currScope,
                                String entityName, Location loc)
        throws XMLStreamException
    {
        boolean check = (mInput == currScope);
        loadMore(getErrorMsg());
        // Did we get out of the scope?
        if (check && (mInput != currScope)) {
            _reportWFCViolation("Unterminated entity value for entity '"
                                +entityName+"' (definition started at "
                                +loc+")");
        }
    }
361370
public static String getScopedStreamName(String scope, String streamName) {
        return getScopedStreamNameInternal(scope, streamName).toString();
    }
870323
public void updateCounter(final String iStatName, final long iPlus) {
    if (iStatName == null)
      return;

    // CHECK IF STATISTICS ARE ACTIVED
    if (recording < 0)
      return;

    synchronized (counters) {
      Long stat = counters.get(iStatName);

      long oldValue = stat == null ? 0 : stat.longValue();

      stat = new Long(oldValue + iPlus);

      counters.put(iStatName, stat);
    }
  }
866360
public void abortTransaction(String scope, String streamName, Duration latency) {
        DYNAMIC_LOGGER.incCounterValue(globalMetricName(ABORT_TRANSACTION), 1);
        DYNAMIC_LOGGER.incCounterValue(ABORT_TRANSACTION, 1, streamTags(scope, streamName));
        abortTransactionLatency.reportSuccessValue(latency.toMillis());
    }
902336
public void addScope(String scope, int maxItemsInMemory) throws Exception {
        // Ignore maxItemsInMemory, since we don't run an eviction algorithm.
        scopeCaches.put(scope, new ConcurrentHashMap<Object, CacheItem>());
    }
1362768
public static Controller.StreamCut decode(final String scope, final String stream, Map<Long, Long> streamCut) {
        return Controller.StreamCut.newBuilder().setStreamInfo(createStreamInfo(scope, stream)).putAllCut(streamCut).build();
    }
1095474
void trackFailure(@Nullable IOException e) {
    assert (!Thread.holdsLock(connectionPool));
    synchronized (connectionPool) {
      if (e instanceof StreamResetException) {
        ErrorCode errorCode = ((StreamResetException) e).errorCode;
        if (errorCode == ErrorCode.REFUSED_STREAM) {
          // Retry REFUSED_STREAM errors once on the same connection.
          refusedStreamCount++;
          if (refusedStreamCount > 1) {
            noNewExchanges = true;
            routeFailureCount++;
          }
        } else if (errorCode != ErrorCode.CANCEL) {
          // Keep the connection for CANCEL errors. Everything else wants a fresh connection.
          noNewExchanges = true;
          routeFailureCount++;
        }
      } else if (!isMultiplexed() || e instanceof ConnectionShutdownException) {
        noNewExchanges = true;

        // If this route hasn't completed a call, avoid it for new connections.
        if (successCount == 0) {
          if (e != null) {
            connectionPool.connectFailed(route, e);
          }
          routeFailureCount++;
        }
      }
    }
  }
1251604
public CompletableFuture<DeleteScopeStatus> deleteScope(final String scope) {
        Exceptions.checkNotNullOrEmpty(scope, "scope");
        return streamStore.deleteScope(scope);
    }
1138526
public void incrementRemoved() {
        if (removed == false && rctxt != null) {
            rctxt.removeWrapper(jspUri);
        }
        removed = true;
    }
743328
public void abortTransactionFailed(String scope, String streamName, String txnId) {
        DYNAMIC_LOGGER.incCounterValue(globalMetricName(ABORT_TRANSACTION_FAILED), 1);
        DYNAMIC_LOGGER.incCounterValue(ABORT_TRANSACTION_FAILED, 1, streamTags(scope, streamName));
        DYNAMIC_LOGGER.incCounterValue(ABORT_TRANSACTION_FAILED, 1, transactionTags(scope, streamName, txnId));
    }