Send the cancellation information of an instance to the node represented
by this class.

@param appName
the application name of the instance.
@param id
the unique identifier of the instance.
@throws Exception
765274
public void cancel(final String appName, final String id) throws Exception {
        long expiryTime = System.currentTimeMillis() + maxProcessingDelayMs;
        batchingDispatcher.process(
                taskId("cancel", appName, id),
                new InstanceReplicationTask(targetHost, Action.Cancel, appName, id) {
                    @Override
                    public EurekaHttpResponse<Void> execute() {
                        return replicationClient.cancel(appName, id);
                    }

                    @Override
                    public void handleFailure(int statusCode, Object responseEntity) throws Throwable {
                        super.handleFailure(statusCode, responseEntity);
                        if (statusCode == 404) {
                            logger.warn("{}: missing entry.", getTaskName());
                        }
                    }
                },
                expiryTime
        );
    }
27023
private boolean monitorApplication(ApplicationId appId)
            throws YarnException, IOException {

        Integer monitorTimes = JOYConstants.MONITOR_TIMES;

        while (true) {

            // Check app status every 1 second.
            try {
                Thread.sleep(JOYConstants.MONITOR_TIME_INTERVAL);
            } catch (InterruptedException e) {
                LOG.debug("Thread sleep in monitoring loop interrupted");
            }
            // Get application report for the appId we are interested in
            ApplicationReport report = jstormClientContext.yarnClient.getApplicationReport(appId);

            try {
                File writename = new File(JOYConstants.RPC_ADDRESS_FILE);
                writename.createNewFile();
                BufferedWriter out = new BufferedWriter(new FileWriter(writename));
                out.write(report.getHost() + JOYConstants.NEW_LINE);
                out.write(report.getRpcPort() + JOYConstants.NEW_LINE);
                out.flush();
                out.close();
            } catch (Exception e) {
                e.printStackTrace();
            }

            LOG.info("Got application report from ASM for"
                    + ", appId=" + appId.getId()
                    + ", clientToAMToken=" + report.getClientToAMToken()
                    + ", appDiagnostics=" + report.getDiagnostics()
                    + ", appMasterHost=" + report.getHost()
                    + ", appQueue=" + report.getQueue()
                    + ", appMasterRpcPort=" + report.getRpcPort()
                    + ", appStartTime=" + report.getStartTime()
                    + ", yarnAppState=" + report.getYarnApplicationState().toString()
                    + ", distributedFinalState=" + report.getFinalApplicationStatus().toString()
                    + ", appTrackingUrl=" + report.getTrackingUrl()
                    + ", appUser=" + report.getUser());

            YarnApplicationState state = report.getYarnApplicationState();
            FinalApplicationStatus dsStatus = report.getFinalApplicationStatus();
            if (YarnApplicationState.FINISHED == state) {
                if (FinalApplicationStatus.SUCCEEDED == dsStatus) {
                    LOG.info("Application has completed successfully. Breaking monitoring loop");
                    return true;
                } else {
                    LOG.info("Application did finished unsuccessfully."
                            + " YarnState=" + state.toString() + ", DSFinalStatus=" + dsStatus.toString()
                            + ". Breaking monitoring loop");
                    return false;
                }
            } else if (YarnApplicationState.KILLED == state
                    || YarnApplicationState.FAILED == state) {
                LOG.info("Application did not finish."
                        + " YarnState=" + state.toString() + ", DSFinalStatus=" + dsStatus.toString()
                        + ". Breaking monitoring loop");
                return false;
            } else if (YarnApplicationState.RUNNING == state) {
                LOG.info("Application is running successfully. Breaking monitoring loop");
                return true;
            } else {
                if (monitorTimes-- <= 0) {
                    forceKillApplication(appId);
                    return false;
                }
            }
        }
    }
570155
@Override
    public EurekaHttpResponse<InstanceInfo> sendHeartBeat(String appName, String id, InstanceInfo info, InstanceStatus overriddenStatus) {
        String urlPath = "apps/" + appName + '/' + id;
        ClientResponse response = null;
        try {
            WebResource webResource = jerseyClient.getClient().resource(serviceUrl)
                    .path(urlPath)
                    .queryParam("status", info.getStatus().toString())
                    .queryParam("lastDirtyTimestamp", info.getLastDirtyTimestamp().toString());
            if (overriddenStatus != null) {
                webResource = webResource.queryParam("overriddenstatus", overriddenStatus.name());
            }
            Builder requestBuilder = webResource.getRequestBuilder();
            addExtraHeaders(requestBuilder);
            response = requestBuilder.accept(MediaType.APPLICATION_JSON_TYPE).put(ClientResponse.class);
            InstanceInfo infoFromPeer = null;
            if (response.getStatus() == Status.CONFLICT.getStatusCode() && response.hasEntity()) {
                infoFromPeer = response.getEntity(InstanceInfo.class);
            }
            return anEurekaHttpResponse(response.getStatus(), infoFromPeer).type(MediaType.APPLICATION_JSON_TYPE).build();
        } finally {
            if (logger.isDebugEnabled()) {
                logger.debug("[heartbeat] Jersey HTTP PUT {}; statusCode={}", urlPath, response == null ? "N/A" : response.getStatus());
            }
            if (response != null) {
                response.close();
            }
        }
    }
338672
@Override
    public int cancel2(long channelId, long callId) throws AsyncException {
        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) {
            Tr.entry(tc, "cancel2: channel = " + channelId + " call id = " + callId);
        }
        int rc = 0;
        synchronized (oneAtATime) {
            if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
                Tr.debug(tc, "have lock");
            }
            if (aioInitialized == AIO_INITIALIZED) {
                try {
                    // Ask the native code to perform a cancel operation
                    rc = aio_cancel2(channelId, callId);
                } catch (Throwable t) {
                    if (aioInitialized != AIO_SHUTDOWN) {
                        if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
                            Tr.debug(tc, "caught throwable:" + t);
                        }
                        throw new AsyncException("Throwable caught from aio dll: aio_cancel2: " + t.getMessage());
                    }
                }
            }
        } // end-sync
        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) {
            Tr.exit(tc, "cancel2: " + rc);
        }
        return rc;
    }
326712
def _cancel_callback(self, request_id):
        """"""
        def callback(future):
            if future.cancelled():
                self.notify(CANCEL_METHOD, {'id': request_id})
                future.set_exception(JsonRpcRequestCancelled())
        return callback
1344357
public void removeApplication(String pid) {
        // remove the application listener from the set we know about and stop it
        ApplicationListeners listeners = _appListeners.remove(pid);

        //check that the app is known, this can be run after the app is already removed.
        if (listeners != null) {
            listeners.stopListeners(true);
        }
    }
458978
public T setAppName(String appName) {
    checkNotNull(appName, "appName");
    builder.appName = appName;
    return self();
  }
299267
public void onApplicationEvent(ApplicationEvent event)
    {
        if ((event instanceof LoginEvent)
                && (event.getSource() != LoginEvent.NO_AUTHENTICATION))
            handleLoginEvent((LoginEvent) event);
        else if ((event instanceof LogoutEvent))
            handleLogoutEvent((LogoutEvent) event);
    }
183488
@Deprecated
    public void setAppId(String appId) {
        checkUserSession("setAppId");
        synchronized (this.lock) {
            mAppId = appId;
            sessionInvalidated = true;
        }
    }
315574
protected void printDead(String interfaceId, ProviderInfo providerInfo, ClientTransport transport, Exception e) {
        Throwable cause = e.getCause();
        if (LOGGER.isWarnEnabled(consumerConfig.getAppName())) {
            LOGGER.warnWithApp(consumerConfig.getAppName(),
                "Connect to {} provider:{} failure !! The exception is " + ExceptionUtils.toShortString(e, 1)
                    + (cause != null ? ", cause by " + cause.getMessage() + "." : "."),
                interfaceId, providerInfo);
        }
    }
1203551
public void restartDyno(String appName, String dynoId) {
        connection.execute(new DynoRestart(appName, dynoId), apiKey);
    }
149440
private void deleteObject(final App app, final Object obj) throws FrameworkException {

		if (obj instanceof NodeInterface) {

			app.delete((NodeInterface)obj);
		}

		if (obj instanceof RelationshipInterface) {

			app.delete((RelationshipInterface)obj);
		}

		if (obj instanceof Iterable) {

			if (batched) {

				final Iterable iterable = (Iterable)obj;
				final Iterator iterator = iterable.iterator();
				int count               = 0;

				while (iterator.hasNext()) {

					try (final Tx tx = app.tx()) {

						while (iterator.hasNext()) {

							deleteObject(app, iterator.next());

							if ((++count % batchSize) == 0) {
								break;
							}
						}

						tx.success();
					}

					logger.debug("Committing batch after {} objects", count);

					// reset count
					count = 0;
				}


			} else {

				for (final Object o : (Iterable)obj) {

					deleteObject(app, o);
				}
			}
		}
	}
478650
public void setAppId(String appId) {
        if (appId == null) {
            _properties.remove(AMQP_PROP_APP_ID);
            return;
        }
        _properties.put(AMQP_PROP_APP_ID, appId);
    }
1129116
@Override
    @Transactional
    public void cancelSnapshot(String snapshotId) throws SnapshotException {
        checkInitialized();
        final Snapshot snapshot = getSnapshot(snapshotId);
        stop(snapshot);
        String snapshotDir = ContentDirUtils.getDestinationPath(snapshotId, this.config.getContentRootDir());
        deleteDirectory(snapshotDir);

        new Thread(new Runnable() {
            @Override
            public void run() {
                final DuracloudEndPointConfig source = snapshot.getSource();
                final String spaceId = source.getSpaceId();
                final ContentStore contentStore =
                    storeClientHelper.create(source,
                                             config.getDuracloudUsername(),
                                             config.getDuracloudPassword());
                try {
                    String result = new Retrier().execute(new Retriable() {
                        /* (non-Javadoc)
                         * @see org.duracloud.common.retry.Retriable#retry()
                         */
                        @Override
                        public Object retry() throws Exception {
                            CompleteCancelSnapshotTaskParameters params =
                                new CompleteCancelSnapshotTaskParameters();
                            params.setSpaceId(spaceId);
                            return contentStore.performTask(SnapshotConstants.COMPLETE_SNAPSHOT_CANCEL_TASK_NAME,
                                                            params.serialize());
                        }
                    });

                    log.info("snapshot cancellation is complete: {}", result);

                    snapshot.setStatus(SnapshotStatus.CANCELLED);
                    snapshot.setStatusText("");
                    eventLog.logSnapshotUpdate(snapshot);
                } catch (Exception ex) {
                    log.error("failed to complete cancellation on the durastore side for space {}:  {}",
                              spaceId,
                              ex.getMessage(),
                              ex);
                }

            }
        }).start();
    }
1008155
@Override
    public void delete(final String id) {
        if (!StringUtils.isEmpty(id)) {
            doDelete(id);
            notifyDeleted(id);
        }
    }
956185
@Override
    public void dismiss(int id) {
        if (restartables.get(id) != null)
            restartables.get(id).dismiss();
    }
162518
public final void setApplicationName(String applicationName) {
        synchronized (lock) {
            if (applicationName == null) {
                serviceProperties.remove(APPLICATION_NAME);
                bundleAnalysingComponentInstantiationListener = null;
            } else {
                serviceProperties.put(APPLICATION_NAME, applicationName);
                bundleAnalysingComponentInstantiationListener =
                    new BundleAnalysingComponentInstantiationListener(bundleContext, injectionSource, factoryTracker);
            }

            if (serviceRegistration != null) {
                serviceRegistration.setProperties(serviceProperties);
            }
        }
    }