/* (non-Javadoc)
@see com.ibm.ws.sib.processor.runtime.SIMPAliasControllable#isReceiveAllowed()
972009
public boolean isReceiveAllowed()
  {
    if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) 
      SibTr.entry(tc, "isReceiveAllowed");
    
    boolean isReceiveAllowed = aliasDest.isReceiveAllowed();
    
    if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) 
      SibTr.exit(tc, "isReceiveAllowed", new Boolean(isReceiveAllowed));
    
    return isReceiveAllowed;
  }
257645
@Check
	public void checkUnmodifiableEventAccess(SarlBehaviorUnit unit) {
		final boolean enable1 = !isIgnored(DISCOURAGED_OCCURRENCE_READONLY_USE);
		final XExpression root = unit.getExpression();
		final String occurrenceKw = this.grammarAccess.getOccurrenceKeyword();
		for (final XFeatureCall child : EcoreUtil2.getAllContentsOfType(root, XFeatureCall.class)) {
			if (occurrenceKw.equals(child.getFeature().getIdentifier())) {
				checkUnmodifiableFeatureAccess(enable1, child, occurrenceKw);
			}
		}
	}
1160947
@Override
    public boolean enableImmediateResponseRead() {
        if (headersSent()) {
            if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
                Tr.debug(tc, "Request hdrs already sent, too late for immediate read");
            }
            return false;
        }
        if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
            Tr.debug(tc, "Immediate response read requested: " + getVC());
        }
        this.bImmediateRead = true;
        return true;
    }
1248980
@Override
    public boolean isApprovalNeeded(final Rollout rollout) {
        final UserDetails userDetails = this.getActor(rollout);
        final boolean approvalEnabled = this.tenantConfigurationManagement
                .getConfigurationValue(TenantConfigurationKey.ROLLOUT_APPROVAL_ENABLED, Boolean.class).getValue();
        return approvalEnabled && userDetails.getAuthorities().stream()
                .noneMatch(authority -> SpPermission.APPROVE_ROLLOUT.equals(authority.getAuthority()));
    }
18052
@Override
    public void notifyRCDReceiveExclusiveChange(boolean isReceiveExclusive)
    {
        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
            SibTr.entry(tc, "notifyRCDReceiveExclusiveChange", new Object[] { Boolean.valueOf(isReceiveExclusive) });

        // Only do this for ptp as it does not seem to make sense for p/s
        if (!isPubSub())
        {
            //if this is a RMQ destination then there is no RCD to
            //worry about, so we only need be concerned with the case of a JS
            //q point.
            if (_ptoPRealization != null)
            {
                _ptoPRealization.getRemoteSupport().
                                notifyRCDReceiveExclusiveChange(isReceiveExclusive);
            }

        }
        else
        {
            // sanity check
            // log error
            SIErrorException e =
                            new SIErrorException(
                                            nls.getFormattedMessage(
                                                                    "INTERNAL_MESSAGING_ERROR_CWSIP0001",
                                                                    new Object[] {
                                                                                  "com.ibm.ws.sib.processor.impl.BaseDestinationHandler",
                                                                                  "1:1458:1.700.3.45" },
                                                                    null));
            FFDCFilter.processException(
                                        e,
                                        "com.ibm.ws.sib.processor.impl.BaseDestinationHandler.notifyRCDReceiveExclusiveChange",
                                        "1:1463:1.700.3.45",
                                        this);
            SibTr.exception(tc, e);

            SibTr.error(tc, "INTERNAL_MESSAGING_ERROR_CWSIP0001",
                        new Object[] {
                                      "com.ibm.ws.sib.processor.impl.BaseDestinationHandler",
                                      "1:1470:1.700.3.45" });

            if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
                SibTr.exit(tc, "notifyRCDReceiveExclusiveChange", e);
        }

        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
            SibTr.exit(tc, "notifyRCDReceiveExclusiveChange");
    }
960014
public final boolean isAlwaysAllowed(final String packageName) {
        if (packageName.equals("java.lang")) {
            return true;
        }
        return Utils.findAllowedByName(getAlwaysAllowed(), packageName) != null;
    }
1293441
public static boolean isPermissionGranted(@NonNull Fragment context, @NonNull String permission) {
        return ActivityCompat.checkSelfPermission(context.getContext(), permission) == PackageManager.PERMISSION_GRANTED;
    }
358452
public final void notifyReceiveExclusiveChange(boolean newValue)
  {
    if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) 
      SibTr.entry(tc, "notifyReceiveExclusiveChange", new Boolean(newValue));
    boolean notifyConsumers = true;
    synchronized (consumerPoints)
    {
      _cardinalityOne = newValue;
      _cardinalityChange = true;

      if (consumerPoints.size() == 0)
      {
        notifyConsumers = false;
      }
      // since we have set cardinalityChange to true, we will not allow any more consumers till we have
      // finished processing the cardinality change
    }

    // if there were consumers, we tell the CD to close all consumers.
    if (notifyConsumers)
      super.closeAllConsumersForReceiveExclusive();
    else
    {
      // all consumers are gone so finish processing the cardinality change
      // NOTE: this causes us to flush the stream.
      // Any outstanding transactions will rollback
      try
      {
        cardinalityChangeConsumersDetached();
      }
      catch(SIResourceException e)
      {
        // Exception shouldn't occur so FFDC and rethrow as runtime exception
        FFDCFilter.processException(
          e,
          "com.ibm.ws.sib.processor.impl.RemoteConsumerDispatcher.notifyReceiveExclusiveChange",
          "1:203:1.75",
          this);

        SIErrorException e2 =
          new SIErrorException(
            nls.getFormattedMessage(
              "INTERNAL_MESSAGING_ERROR_CWSIP0002",
              new Object[] { "com.ibm.ws.sib.processor.impl.RemoteConsumerDispatcher.notifyReceiveExclusiveChange",
                             "1:211:1.75",
                             e },
              null));

        SibTr.exception(tc, e);
        SibTr.error(tc, "INTERNAL_MESSAGING_ERROR_CWSIP0002",
          new Object[] {
            "com.ibm.ws.sib.processor.impl.RemoteConsumerDispatcher.notifyReceiveExclusiveChange",
            "1:219:1.75",
            e });
        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) SibTr.exit(tc, "notifyReceiveExclusiveChange", e2);
        throw e2;
      }
    }
    if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) SibTr.exit(tc, "notifyReceiveExclusiveChange");
  }
663855
public boolean isSendAllowed()
  {
    if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
      SibTr.entry(tc, "isSendAllowed");
    
    boolean sendAllowed;
    if(_sendAllowedOnTargetForeignBus.equals(Boolean.FALSE))
      sendAllowed =  false;
    else
      sendAllowed = _foreignDestinationDefault.isSendAllowed();     
    
    if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
      SibTr.exit(tc, "isSendAllowed", sendAllowed);
    
    return sendAllowed;
  }
853602
public boolean isReallocationRequired(SIMPMessage msg)
    throws SIResourceException
  {
    if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
      SibTr.entry(tc, "isReallocationRequired", new Object[] { msg });

    boolean reallocate = false;

    JsMessage jsMsg = msg.getMessage();
    SIBUuid12 streamID = msg.getGuaranteedStreamUuid();
    StreamSet streamSet = getStreamSet();

    if(!streamID.equals(streamSet.getStreamID()))
    {
      SIResourceException e = new SIResourceException(
                                nls.getFormattedMessage(
                                  "INTERNAL_MESSAGING_ERROR_CWSIP0001",
                                  new Object[] {
                                    "com.ibm.ws.sib.processor.gd.SourceStreamManager",
                                    "1:717:1.102"},
                                  null));

      // FFDC
      FFDCFilter.processException(
        e,
        "com.ibm.ws.sib.processor.gd.SourceStreamManager.isReallocationRequired",
        "1:724:1.102",
        this);

      SibTr.exception(tc, e);
      SibTr.error(tc, "INTERNAL_MESSAGING_ERROR_CWSIP0001",
        new Object[] {
          "com.ibm.ws.sib.processor.gd.SourceStreamManager",
          "1:731:1.102"});

      if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
        SibTr.exit(tc, "isReallocationRequired", e);

      throw e;
    }

    int priority = msg.getPriority();
    Reliability reliability = msg.getReliability();

    // Get the stream. Note that no synchronization is required here
    // since we can't be here if a flush is in progress.
    SourceStream sourceStream = (SourceStream) streamSet.getStream(priority,reliability);

    if(sourceStream != null)
    {
      TickRange tr = sourceStream.getTickRange(jsMsg.getGuaranteedValueValueTick());

      // Need to check if it was in uncommitting state AND if it is still outside
      // the send window.
      if (tr.isReallocationRequired() && 
          sourceStream.isOutsideSendWindow(jsMsg.getGuaranteedValueValueTick()))
        reallocate = true;
    }

    if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
      SibTr.exit(tc, "isReallocationRequired", Boolean.valueOf(reallocate));

    return reallocate;
  }
658019
private boolean checkReceiveAllowed() throws SISessionUnavailableException, SIResourceException
    {
        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
            SibTr.entry(tc, "checkReceiveAllowed");

        boolean allowed = _destinationAttachedTo.isReceiveAllowed();

        if (!allowed)
        {
            // Register that LCP stopped for Receive Allowed
            _stoppedForReceiveAllowed = true;

            // Stop LCP for Receive Allowed
            if (!_stopped)
            {
                internalStop();
            }
        }
        else
        {
            // Register that LCP not stopped for Receive Allowed
            _stoppedForReceiveAllowed = false;

            // Start LCP if no reason to be stopped
            if ((_stopped)
                && (!_stoppedByRequest))
            {
                internalStart(false);
            }
        }

        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
            SibTr.exit(tc, "checkReceiveAllowed", Boolean.valueOf(allowed));

        return allowed;
    }
979017
@Override
    public synchronized boolean isNotificationEnabled(Notification notification) {
        if (filters.isEmpty()) {
            //Allow all
            return true;
        }

        final Iterator<NotificationFilter> i = filters.iterator();
        while (i.hasNext()) {
            if (i.next().isNotificationEnabled(notification)) {
                return true;
            }
        }

        return false;
    }
96932
public boolean isAccepted(IRequestInfo req) {
        boolean answer = true;
        if (processAll) {
            if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
                Tr.debug(tc, "processAll is true, therefore we always intercept.");
            }
            return answer;
        }

        String HTTPheader = null;

        Iterator<ICondition> iter = filterCondition.iterator();
        while (iter.hasNext()) {
            ICondition cond = iter.next();
            String key = cond.getKey();

            // Start with request header attribute name
            HTTPheader = req.getHeader(key);

            boolean ipAddress = false;

            // The header argument is a null, so go through other tags.
            if (HTTPheader == null) {
                if (key.equals(REMOTE_ADDRESS)) {
                    HTTPheader = req.getRemoteAddr();
                    ipAddress = true;
                } else if (key.equals(REQUEST_URL)) {
                    HTTPheader = req.getRequestURL();
                } else if (key.equals(AuthFilterConfig.KEY_WEB_APP) || key.equals(APPLICATION_NAMES)) {
                    HTTPheader = req.getApplicationName();
                } else if (key.equals(AuthFilterConfig.KEY_COOKIE)) {
                    HTTPheader = req.getCookieName(key);
                } else if (cond instanceof NotContainsCondition) {
                    continue;
                } else {
                    if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
                        Tr.debug(tc, "No HTTPheader found, and no remote-address, request-url, webApp, applicationNames, cookie, or requestHeader rule used - do not Intercept.");
                    }
                    return false; // if no header found, the condition fails
                }
            }
            if (HTTPheader == null) {
                if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
                    Tr.debug(tc, "No HTTPheader found - do not Intercept.");
                }
                return false; // if no header found, the condition fails
            }

            if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
                Tr.debug(tc, "Checking condition {0} {1}.", new Object[] { cond, HTTPheader });
            }
            try {
                IValue compareValue;
                if (ipAddress) {
                    compareValue = new ValueIPAddress(HTTPheader);
                } else {
                    compareValue = new ValueString(HTTPheader);
                }
                answer = cond.checkCondition(compareValue);
                if (!answer) {
                    break;
                }

            } catch (FilterException e) {
                throw new RuntimeException(e);
            }
        }
        return answer;
    }
1206392
public boolean isProducerQOSOverrideEnabled()
  {
    if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) 
      SibTr.entry(tc, "isProducerQOSOverrideEnabled");    
    boolean allowed = aliasDest.isOverrideOfQOSByProducerAllowed();    
    if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) 
      SibTr.exit(tc, "isProducerQOSOverrideEnabled", new Boolean(allowed));   
    return allowed;
  }
1064183
@Override
    public void onReceive(Object message) {
        try {
            // Start all workers
            if (message instanceof InitialRequestToManager) {
                director = getSender();
                logger.info("parallec task state : "
                        + ParallelTaskState.IN_PROGRESS.toString());
                task.setState(ParallelTaskState.IN_PROGRESS);
                task.setExecuteStartTime(startTime);

                taskId = task.getTaskId();

                // assumption: at least REDUCE_LEN
                taskIdTrim = taskId.length() <= REDUCE_LEN ? taskId : taskId
                        .substring(taskId.length() - REDUCE_LEN,
                                taskId.length());

                httpMeta = task.getHttpMeta();
                targetHostMeta = task.getTargetHostMeta();
                final RequestProtocol requestProtocol = task
                        .getRequestProtocol();

                // Get request parameters to construct a REST CALL
                final String requestUrlPrefixOrig = httpMeta
                        .getRequestUrlPostfix();
                final HttpMethod httpMethod = httpMeta.getHttpMethod();

                String requestPortStrOrig = httpMeta.getRequestPort();

                final boolean pollable = httpMeta.isPollable();

                final int maxConcurrency = task.getConcurrency();

                Map<String, NodeReqResponse> nodeDataMapValid = task
                        .getParallelTaskResult();

                logger.info("Before Safety Check: total entry count: "
                        + nodeDataMapValid.size());

                Map<String, NodeReqResponse> nodeDataMapValidSafe = new HashMap<String, NodeReqResponse>();

                InternalDataProvider.getInstance()
                        .filterUnsafeOrUnnecessaryRequest(nodeDataMapValid,
                                nodeDataMapValidSafe);

                logger.info(
                        "After Safety Check: total entry count in nodeDataMapValidSafe: {}",
                        nodeDataMapValidSafe.size());

                logger.debug("maxConcurrency : {}", maxConcurrency);

                // after filter, no duplicated target hosts for this count.
                requestCount = nodeDataMapValidSafe.size();
                task.setRequestNumActual(requestCount);

                logger.info("!Obtain command request for target host meta id "
                        + targetHostMeta.getTargetHostId() + "  with count: "
                        + requestCount);
                // If there are no target hosts in the incoming message, send a
                // message back
                if (requestCount <= 0) {
                    getSender().tell(new ResponseFromManager(requestCount),
                            getSelf());
                    logger.info("req count <=0. return");
                    // not really error. just no task to run
                    reply(ParallelTaskState.COMPLETED_WITHOUT_ERROR,
                            new RuntimeException(
                                    "ReqCount after trim is 0. Return."));
                    return;
                }

                int sentRequestCounter = 0;

                asyncHttpClientGlobal = task.getAsyncHttpClient();

                final AsyncHttpClient asyncHttpClient = asyncHttpClientGlobal;

                // always send with valid safe data.
                for (Entry<String, NodeReqResponse> entry : nodeDataMapValidSafe
                        .entrySet()) {

                    final String targetHost = entry.getKey();
                    NodeReqResponse nodeReqResponse = entry.getValue();

                    final String requestContentOrig = nodeReqResponse
                            .getRequestParameters().get(
                                    PcConstants.REQUEST_BODY_PLACE_HOLDER);

                    final String requestContent = NodeReqResponse
                            .replaceStrByMap(
                                    nodeReqResponse.getRequestParameters(),
                                    requestContentOrig);
                    final String resourcePath = NodeReqResponse
                            .replaceStrByMap(
                                    nodeReqResponse.getRequestParameters(),
                                    requestUrlPrefixOrig);
                    // add support for port replacement
                    final String requestPortStr = NodeReqResponse
                            .replaceStrByMap(
                                    nodeReqResponse.getRequestParameters(),
                                    requestPortStrOrig);
                    int requestPort = 80;
                    try {
                        requestPort = Integer.parseInt(requestPortStr);
                    } catch (NumberFormatException nfe) {
                        logger.error(
                                "Error parsing replacable port with NumberFormatException. "
                                        + "No valid port for host {}. Now use default port 80",
                                targetHost);
                    }
                    // only pass when it is not in manager
                    final ParallecResponseHandler handler = task.getConfig()
                            .getHandlerExecutionLocation() == HandlerExecutionLocation.MANAGER ? null
                            : task.getHandler();
                    final Map<String, Object> responseContext = task
                            .getConfig().getHandlerExecutionLocation() == HandlerExecutionLocation.MANAGER ? null
                            : task.getResponseContext();
                    Map<String, String> httpHeaderMapLocal = new HashMap<String, String>();
                    httpHeaderMapLocal.putAll(httpMeta.getHeaderMetadata()
                            .getHeaderMap());

                    // 3rd, add the dynamic part ; generic var based
                    // replacement.
                    PcHttpUtils.replaceHttpHeaderMapNodeSpecific(
                            httpHeaderMapLocal,
                            nodeReqResponse.getRequestParameters());

                    /**
                     * If want to print to check
                     */
                    if (task.getConfig().isPrintHttpTrueHeaderMap()) {

                        for (Entry<String, String> headerEntry : httpHeaderMapLocal
                                .entrySet()) {
                            String headerKey = headerEntry.getKey();
                            String headerValue = headerEntry.getValue();

                            nodeReqResponse
                                    .getRequestParameters()
                                    .put(PcConstants.REQUEST_PARAMETER_HTTP_HEADER_PREFIX
                                            + headerKey, headerValue);
                        }

                    }

                    if (task.getConfig().isPrintPoller()) {
                        // put the one before encoding
                        nodeReqResponse.getRequestParameters().put(
                                PcConstants.NODE_REQUEST_NEED_POLLER,
                                Boolean.toString(pollable));
                    }

                    /**
                     * 20140310: END add pass HTTP header into Operation worker
                     * as part of the
                     */

                    String targetHostNew = nodeReqResponse
                            .getRequestParameters()
                            .get(PcConstants.UNIFORM_TARGET_HOST_VAR_WHEN_CHECK);
                    if (targetHostNew != null) {
                        nodeReqResponse.getRequestParameters().put(
                                PcConstants.NODE_REQUEST_TRUE_TARGET_NODE,
                                targetHostNew);
                    }

                    final String hostUniform = (targetHostNew == null) ? null
                            : targetHostNew;

                    nodeReqResponse.getRequestParameters().put(
                            PcConstants.NODE_REQUEST_STATUS,
                            SingleTargetTaskStatus.IN_PROGRESS.toString());

                    nodeReqResponse.getRequestParameters().put(
                            PcConstants.NODE_REQUEST_TRUE_CONTENT,
                            requestContent);

                    // put the one before encoding
                    nodeReqResponse.getRequestParameters().put(
                            PcConstants.NODE_REQUEST_TRUE_URL, resourcePath);

                    nodeReqResponse.getRequestParameters().put(
                            PcConstants.NODE_REQUEST_TRUE_PORT,
                            Integer.toString(requestPort));

                    nodeReqResponse.getRequestParameters().put(
                            PcConstants.NODE_REQUEST_HTTP_HEADER_META,
                            httpMeta.getHeaderMetadata().getHeaderStr());

                    long prepareRequestTime = System.currentTimeMillis();

                    String prepareRequestTimeStr = PcDateUtils
                            .getDateTimeStrStandard(new Date(prepareRequestTime));
                    nodeReqResponse.getRequestParameters().put(
                            PcConstants.NODE_REQUEST_PREPARE_TIME,
                            prepareRequestTimeStr);

                    final SshMeta sshMeta = task.getSshMeta();
                    final TcpMeta tcpMeta = task.getTcpMeta();
                    final UdpMeta udpMeta = task.getUdpMeta();

                    final PingMeta pingMeta = task.getPingMeta();
                    final ResponseHeaderMeta responseHeaderMeta = task
                            .getHttpMeta().getResponseHeaderMeta();

                    logger.debug("REQUEST GENERATED: "
                            + (sentRequestCounter + 1)
                            + " / "
                            + requestCount
                            + " after "
                            + Double.toString((prepareRequestTime - startTime) / 1000.0)
                            + " secs" + ":  (NOT SEND YET) " + targetHost
                            + " at " + prepareRequestTimeStr);

                    ActorRef worker = getContext().system().actorOf(
                            Props.create(OperationWorker.class,
                                    new TaskRequest(task.getConfig()
                                            .getActorMaxOperationTimeoutSec(),
                                            requestProtocol, targetHost,
                                            hostUniform, requestPort,
                                            resourcePath, requestContent,
                                            httpMethod, pollable,
                                            httpHeaderMapLocal, handler,
                                            responseContext, sshMeta, tcpMeta,
                                            udpMeta, pingMeta,
                                            responseHeaderMeta),
                                    asyncHttpClient, task.getHttpMeta()
                                            .getHttpPollerProcessor()

                            ));

                    workers.put(targetHost, worker);

                    ++sentRequestCounter;

                }// end for loop

                final RequestToBatchSenderAsstManager requestToBatchSenderAsstManager = new RequestToBatchSenderAsstManager(
                        taskId, task.getConfig()
                                .getAsstManagerRetryIntervalMillis(),
                        new ArrayList<ActorRef>(workers.values()), getSelf(),
                        maxConcurrency);

                batchSenderAsstManager = getContext().system().actorOf(
                        Props.create(AssistantExecutionManager.class),
                        "RequestToBatchSenderAsstManager-"
                                + UUID.randomUUID().toString());

                batchSenderAsstManager.tell(requestToBatchSenderAsstManager,
                        getSelf());

                final FiniteDuration timeOutDuration = Duration
                        .create(task.getConfig().getTimeoutInManagerSec(),
                                TimeUnit.SECONDS);
                timeoutMessageCancellable = getContext()
                        .system()
                        .scheduler()
                        .scheduleOnce(timeOutDuration, getSelf(),
                                ExecutionManagerMsgType.OPERATION_TIMEOUT,
                                getContext().system().dispatcher(), getSelf());

                logger.debug(
                        "Scheduled TIMEOUT_IN_MANAGER_SCONDS OPERATION_TIMEOUT after SEC {} ",
                        task.getConfig().getTimeoutInManagerSec());
            } else if (message instanceof ResponseOnSingleTask) {

                ResponseOnSingleTask taskResponse = (ResponseOnSingleTask) message;

                this.responseCount += 1;
                task.setResponsedNum(responseCount);

                /**
                 * add feedback of current responseCount to asst manager
                 * ResponseCountToBatchSenderAsstManager
                 */
                final ResponseCountToBatchSenderAsstManager responseCountToBatchSenderAsstManager = new ResponseCountToBatchSenderAsstManager(
                        this.responseCount);

                batchSenderAsstManager.tell(
                        responseCountToBatchSenderAsstManager, getSelf());

                logger.debug("Send batchSenderAsstManager to responseCountToBatchSenderAsstManager: "
                        + this.responseCount);

                String hostName = taskResponse.getRequest().getHost();
                if (responseMap.containsKey(hostName)) {
                    logger.error("ERROR: duplicate response received {}", hostName);
                }
                responseMap.put(hostName, taskResponse);

                String responseSummary = taskResponse.isError() ? "FAIL_GET_RESPONSE: "
                        + taskResponse.getErrorMessage()
                        : taskResponse.getStatusCode();
                Map<String, LinkedHashSet<String>> resultMap = task
                        .getAggregateResultMap();
                if (resultMap.containsKey(responseSummary)) {
                    resultMap.get(responseSummary).add(hostName);
                } else {
                    LinkedHashSet<String> set = new LinkedHashSet<String>();
                    set.add(hostName);
                    resultMap.put(responseSummary, set);
                }

                // save response to result map
                NodeReqResponse nrr = task.getParallelTaskResult()
                        .get(hostName);
                nrr.setSingleTaskResponse(taskResponse);

                String responseTrim = taskResponse.getResponseContent() == null ? null
                        : taskResponse.getResponseContent().trim();
                String displayResponse = (Strings.isNullOrEmpty(responseTrim)) ? "EMPTY"
                        : responseTrim
                                .substring(
                                        0,
                                        Math.min(
                                                PcConstants.AGNET_RESPONSE_MAX_RESPONSE_DISPLAY_BYTE,
                                                responseTrim.length()));

                long responseReceiveTime = System.currentTimeMillis();
                // %.5g%n
                double progressPercent = (double) (responseCount)
                        / (double) (requestCount) * 100.0;
                String responseReceiveTimeStr = PcDateUtils
                        .getDateTimeStrStandard(new Date(responseReceiveTime));
                String secondElapsedStr = Double
                        .toString((responseReceiveTime - startTime) / 1000.0);

                // log the first/ last 5 percent; then sample the middle
                if (requestCount < ParallecGlobalConfig.logAllResponseIfTotalLessThan
                        || responseCount <= ParallecGlobalConfig.logAllResponseBeforeInitCount
                        || progressPercent < ParallecGlobalConfig.logAllResponseBeforePercent
                        || progressPercent > ParallecGlobalConfig.logAllResponseAfterPercent
                        || responseCount
                                % ParallecGlobalConfig.logResponseInterval == 0) {
                    // percent is escaped using percent sign; hostName
                    logger.info(String
                            .format("\n[%d]__RESP_RECV_IN_MGR %d (+%d) / %d (%.5g%%)  "
                                    + "AFT %s S @ %s @ %s , TaskID : %s , CODE: %s, RESP_BRIEF: %s %s",
                                    responseCount,
                                    responseCount,
                                    requestCount - responseCount,
                                    requestCount,
                                    progressPercent,
                                    secondElapsedStr,
                                    hostName,
                                    responseReceiveTimeStr,
                                    taskIdTrim,
                                    taskResponse.getStatusCode(),
                                    displayResponse,
                                    taskResponse.getErrorMessage() == null ? ""
                                            : ", ERR: "
                                                    + taskResponse
                                                            .getErrorMessage()));
                }

                nrr.getRequestParameters().put(PcConstants.NODE_REQUEST_STATUS,
                        SingleTargetTaskStatus.COMPLETED.toString());

                if (task.getConfig().getHandlerExecutionLocation() == HandlerExecutionLocation.MANAGER
                        && task != null && task.getHandler() != null) {
                    try {
                        // logger.debug("HANDLE In manager: " +
                        // taskResponse.getHost());
                        task.getHandler().onCompleted(taskResponse,
                                task.getResponseContext());
                    } catch (Exception t) {
                        logger.error(
                                "Error handling onCompleted in manager for response: {} Error {}",
                                taskResponse.toString(),
                                t.getLocalizedMessage());
                    }
                }

                if (!task.getConfig().isSaveResponseToTask()) {
                    taskResponse.setResponseContent(PcConstants.NOT_SAVED);
                    taskResponse.setResponseHeaders(null);
                    logger.debug("Erased single task response content and response headers to save space.");
                }

                if (this.responseCount == this.requestCount) {
                    if (wasIssuedCancel) {
                        ExecutionManagerExecutionException exCanceled = new ExecutionManagerExecutionException(
                                "ExecutionManager: task was canceled by user",
                                ManagerExceptionType.CANCEL);
                        reply(ParallelTaskState.COMPLETED_WITH_ERROR,
                                exCanceled);
                    } else {
                        reply(ParallelTaskState.COMPLETED_WITHOUT_ERROR, null);
                    }

                }// end when all requests have resonponse

            } else if (message instanceof CancelTaskOnHostRequest) {
                CancelTaskOnHostRequest msg = (CancelTaskOnHostRequest) message;
                cancelRequestAndWorkerOnHost(msg.getTargetHosts());

            } else if (message instanceof ExecutionManagerMsgType) {
                switch ((ExecutionManagerMsgType) message) {

                // this will immediately return. not waiting for the op workers
                // reply
                case OPERATION_TIMEOUT:
                    cancelRequestAndWorkers();
                    String msg = "Execution manager timeout on whole Parallel Task.";
                    ExecutionManagerExecutionException ex = new ExecutionManagerExecutionException(
                            msg,
                            ManagerExceptionType.TIMEOUT);
                    logger.error(msg);
                    reply(ParallelTaskState.COMPLETED_WITH_ERROR, ex);
                    
                    break;
                // this will wait for the works to reply.
                case CANCEL:
                    cancelRequestAndWorkers();
                    wasIssuedCancel = true;
                    break;
                default:
                    break;
                }
            } else {
                logger.error("Unhandled: " + message);
                unhandled(message);
            }

        } catch (Exception t) {
            logger.error("Command Manager error: " + t + " trace: ", t);

            // not to terminate: but add error details. Will exit after timeout
            // or cancel
            task.getTaskErrorMetas().add(
                    new TaskErrorMeta(TaskErrorType.COMMAND_MANAGER_ERROR,
                            t == null ? "NA" : t.getLocalizedMessage()));
            reply(ParallelTaskState.COMPLETED_WITH_ERROR, t);

        }

    }
1363332
public static boolean checkReceiver(Context context, Class<?> receiver) {
    try {
      ActivityInfo info = context.getPackageManager().getReceiverInfo(
          new ComponentName(context, receiver), 0);
      return null != info;
    } catch (PackageManager.NameNotFoundException e) {
      printErrorLog("receiver " + receiver.getName() + " is missing!");
      return false;
    }
  }
178296
@Override
    public boolean isSendAllowed()
    {
        if (tc.isEntryEnabled())
            SibTr.entry(tc, "isSendAllowed");

        boolean isSendAllowed = true;

        // We check first whether send is disallowed at the bus definition level. A 
        // setting at the bus level overrides a setting on the Foreign Destination
        // Definition.
        if (_sendAllowedOnTargetForeignBus != null)
            isSendAllowed = _sendAllowedOnTargetForeignBus.booleanValue();

        // If allowed at the bus level, check at the foreign dest def level
        if (isSendAllowed)
            isSendAllowed = _definition.isSendAllowed();

        if (tc.isEntryEnabled())
            SibTr.exit(tc, "isSendAllowed", new Boolean(isSendAllowed));

        return isSendAllowed;
    }