本文整理汇总了Java中com.google.cloud.tools.appengine.cloudsdk.process.ProcessStartListener类的典型用法代码示例。如果您正苦于以下问题:Java ProcessStartListener类的具体用法?Java ProcessStartListener怎么用?Java ProcessStartListener使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ProcessStartListener类属于com.google.cloud.tools.appengine.cloudsdk.process包,在下文中一共展示了ProcessStartListener类的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: execute
import com.google.cloud.tools.appengine.cloudsdk.process.ProcessStartListener; //导入依赖的package包/类
@Override
public void execute(ProcessStartListener startListener) {
UsageTrackerProvider.getInstance().trackEvent(GctTracking.APP_ENGINE_STOP).ping();
try {
if (stop.getHelper().stageCredentials(stop.getDeploymentConfiguration().getGoogleUsername())
== null) {
stop.getCallback()
.errorOccurred(GctBundle.message("appengine.staging.credentials.error.message"));
return;
}
stop.stop(module, version, startListener);
} catch (RuntimeException re) {
stop.getCallback().errorOccurred(GctBundle.message("appengine.stop.modules.version.error"));
logger.error(re);
}
}
示例2: execute
import com.google.cloud.tools.appengine.cloudsdk.process.ProcessStartListener; //导入依赖的package包/类
@Override
public void execute(ProcessStartListener startListener) {
CloudSdkService sdkService = CloudSdkService.getInstance();
// show a warning notification if the cloud sdk version is not supported
CloudSdkVersionNotifier.getInstance().notifyIfUnsupportedVersion();
CloudSdk.Builder sdkBuilder =
new CloudSdk.Builder()
.sdkPath(sdkService.getSdkHomePath())
.async(true)
.startListener(startListener);
if (javaSdk.getHomePath() != null) {
sdkBuilder.javaHome(Paths.get(javaSdk.getHomePath()));
}
CloudSdkAppEngineDevServer1 devServer = new CloudSdkAppEngineDevServer1(sdkBuilder.build());
devServer.run(runConfig);
UsageTrackerProvider.getInstance()
.trackEvent(GctTracking.APP_ENGINE_RUN)
.addMetadata(GctTracking.METADATA_LABEL_KEY, Strings.nullToEmpty(runnerId))
.ping();
}
示例3: deploy
import com.google.cloud.tools.appengine.cloudsdk.process.ProcessStartListener; //导入依赖的package包/类
@VisibleForTesting
ProcessExitListener deploy(
@NotNull final Path stagingDirectory, @NotNull final ProcessStartListener startListener) {
return (exitCode) -> {
if (exitCode == 0) {
try {
deploy.deploy(stagingDirectory, startListener);
} catch (RuntimeException re) {
deploy
.getCallback()
.errorOccurred(
GctBundle.message("appengine.deployment.exception")
+ "\n"
+ GctBundle.message("appengine.action.error.update.message"));
logger.error(re);
}
} else {
deploy
.getCallback()
.errorOccurred(
GctBundle.message("appengine.deployment.error.during.staging", exitCode));
logger.warn(
"App engine standard staging process exited with an error. Exit Code:" + exitCode);
}
};
}
示例4: deploy_exception
import com.google.cloud.tools.appengine.cloudsdk.process.ProcessStartListener; //导入依赖的package包/类
@Test
public void deploy_exception() {
doThrow(new RuntimeException())
.when(deploy)
.deploy(any(Path.class), any(ProcessStartListener.class));
try {
task.execute(startListener);
} catch (AssertionError ae) {
verify(callback, times(1))
.errorOccurred(
"Deployment failed with an exception.\n"
+ "Please make sure that you are using the latest version of the Google Cloud "
+ "SDK.\nRun ''gcloud components update'' to update the SDK. "
+ "(See: https://cloud.google.com/sdk/gcloud/reference/components/update.)");
return;
}
fail("Expected exception due to log error level");
}
开发者ID:GoogleCloudPlatform,项目名称:google-cloud-intellij,代码行数:21,代码来源:AppEngineFlexibleDeployTaskTest.java
示例5: runSynchronousGcloudCommand
import com.google.cloud.tools.appengine.cloudsdk.process.ProcessStartListener; //导入依赖的package包/类
private String runSynchronousGcloudCommand(List<String> args) throws ProcessRunnerException {
validateCloudSdkLocation();
StringBuilderProcessOutputLineListener stdOutListener =
new StringBuilderProcessOutputLineListener();
ExitCodeRecorderProcessExitListener exitListener = new ExitCodeRecorderProcessExitListener();
// instantiate a separate synchronous process runner
ProcessRunner runner =
new DefaultProcessRunner(
false, /* async */
ImmutableList.<ProcessExitListener>of(exitListener), /* exitListeners */
ImmutableList.<ProcessStartListener>of(), /* startListeners */
ImmutableList.<ProcessOutputLineListener>of(stdOutListener), /* stdOutLineListeners */
ImmutableList.<ProcessOutputLineListener>of()); /* stdErrLineListeners */
// build and run the command
List<String> command =
new ImmutableList.Builder<String>().add(getGCloudPath().toString()).addAll(args).build();
runner.run(command.toArray(new String[command.size()]));
if (exitListener.getMostRecentExitCode() != null
&& !exitListener.getMostRecentExitCode().equals(0)) {
throw new ProcessRunnerException("Process exited unsuccessfully");
}
return stdOutListener.toString();
}
示例6: DefaultProcessRunner
import com.google.cloud.tools.appengine.cloudsdk.process.ProcessStartListener; //导入依赖的package包/类
/**
* Base constructor.
*
* @param async whether to run commands asynchronously
* @param exitListeners client consumers of process onExit event
* @param startListeners client consumers of process onStart event
*/
public DefaultProcessRunner(
boolean async,
List<ProcessExitListener> exitListeners,
List<ProcessStartListener> startListeners,
boolean inheritProcessOutput) {
this.async = async;
this.exitListeners = exitListeners;
this.startListeners = startListeners;
this.inheritProcessOutput = inheritProcessOutput;
}
示例7: stop
import com.google.cloud.tools.appengine.cloudsdk.process.ProcessStartListener; //导入依赖的package包/类
/** Stops the given module / version of an App Engine application. */
public void stop(
@NotNull String module,
@NotNull String version,
@NotNull ProcessStartListener startListener) {
ProcessOutputLineListener outputListener =
new ProcessOutputLineListener() {
@Override
public void onOutputLine(String line) {
loggingHandler.print(line + "\n");
}
};
ProcessExitListener stopExitListener = new StopExitListener();
CloudSdk sdk =
helper.createSdk(
loggingHandler, startListener, outputListener, outputListener, stopExitListener);
DefaultVersionsSelectionConfiguration configuration =
new DefaultVersionsSelectionConfiguration();
configuration.setVersions(Collections.singletonList(version));
configuration.setService(module);
configuration.setProject(deploymentConfiguration.getCloudProjectName());
CloudSdkAppEngineVersions command = new CloudSdkAppEngineVersions(sdk);
command.stop(configuration);
}
示例8: stage
import com.google.cloud.tools.appengine.cloudsdk.process.ProcessStartListener; //导入依赖的package包/类
/**
* Stage the application in preparation for deployment to the App Engine standard environment.
*
* @param stagingDirectory the local staging directory
* @param onStageComplete a callback for executing actions on completion of staging
*/
public void stage(
@NotNull Path stagingDirectory,
@NotNull ProcessStartListener startListener,
@NotNull ProcessExitListener onStageComplete) {
ProcessOutputLineListener outputListener =
new ProcessOutputLineListener() {
@Override
public void onOutputLine(String line) {
loggingHandler.print(line + "\n");
}
};
CloudSdk sdk =
helper.createSdk(
loggingHandler, startListener, outputListener, outputListener, onStageComplete);
// TODO determine the default set of flags we want to set for AE standard staging
DefaultStageStandardConfiguration stageConfig = new DefaultStageStandardConfiguration();
stageConfig.setEnableJarSplitting(true);
// TODO(joaomartins): Change File to Path on library configs.
stageConfig.setStagingDirectory(stagingDirectory.toFile());
stageConfig.setSourceDirectory(deploymentArtifactPath.toFile());
CloudSdkAppEngineStandardStaging staging = new CloudSdkAppEngineStandardStaging(sdk);
staging.stageStandard(stageConfig);
}
示例9: createSdk
import com.google.cloud.tools.appengine.cloudsdk.process.ProcessStartListener; //导入依赖的package包/类
@Override
public CloudSdk createSdk(
LoggingHandler loggingHandler,
ProcessStartListener startListener,
ProcessOutputLineListener logListener,
ProcessOutputLineListener outputListener,
ProcessExitListener exitListener) {
if (credentialsPath == null) {
loggingHandler.print(GctBundle.message("appengine.action.credential.not.found") + "\n");
throw new AppEngineException("Failed to create application default credentials.");
}
CloudToolsPluginInfoService pluginInfoService =
ServiceManager.getService(CloudToolsPluginInfoService.class);
CloudSdk.Builder sdkBuilder =
new CloudSdk.Builder()
.sdkPath(CloudSdkService.getInstance().getSdkHomePath())
.async(true)
.addStdErrLineListener(logListener)
.addStdOutLineListener(outputListener)
.exitListener(exitListener)
.startListener(startListener)
.appCommandCredentialFile(credentialsPath.toFile())
.appCommandMetricsEnvironment(pluginInfoService.getExternalPluginName())
.appCommandMetricsEnvironmentVersion(pluginInfoService.getPluginVersion())
.appCommandOutputFormat("json");
getProjectJavaSdk(project).ifPresent(sdkBuilder::javaHome);
return sdkBuilder.build();
}
示例10: run
import com.google.cloud.tools.appengine.cloudsdk.process.ProcessStartListener; //导入依赖的package包/类
/**
* Executes a shell command.
*
* <p>If any output listeners were configured, output will go to them only. Otherwise, process
* output will be redirected to the caller via inheritIO.
*
* @param command the shell command to execute
*/
@Override
public void run(String[] command) throws ProcessRunnerException {
try {
// Configure process builder.
final ProcessBuilder processBuilder = new ProcessBuilder();
// If there are no listeners, we might still want to redirect stdout and stderr to the parent
// process, or not.
if (stdOutLineListeners.isEmpty() && inheritProcessOutput) {
processBuilder.redirectOutput(Redirect.INHERIT);
}
if (stdErrLineListeners.isEmpty() && inheritProcessOutput) {
processBuilder.redirectError(Redirect.INHERIT);
}
if (environment != null) {
processBuilder.environment().putAll(environment);
}
processBuilder.directory(workingDirectory);
processBuilder.command(command);
Process process = processBuilder.start();
Thread stdOutHandler = null;
Thread stdErrHandler = null;
// Only handle stdout or stderr if there are listeners.
if (!stdOutLineListeners.isEmpty()) {
stdOutHandler = handleStdOut(process);
}
if (!stdErrLineListeners.isEmpty()) {
stdErrHandler = handleErrOut(process);
}
for (ProcessStartListener startListener : startListeners) {
startListener.onStart(process);
}
if (async) {
asyncRun(process, stdOutHandler, stdErrHandler);
} else {
shutdownProcessHook(process);
syncRun(process, stdOutHandler, stdErrHandler);
}
} catch (IOException | InterruptedException e) {
throw new ProcessRunnerException(e);
}
}
示例11: deploy
import com.google.cloud.tools.appengine.cloudsdk.process.ProcessStartListener; //导入依赖的package包/类
/** Given a staging directory, deploy the application to Google App Engine. */
// TODO(eshaul) break this down into smaller parts
public void deploy(
@NotNull Path stagingDirectory, @NotNull ProcessStartListener deployStartListener) {
final StringBuilder rawDeployOutput = new StringBuilder();
DefaultDeployConfiguration configuration = new DefaultDeployConfiguration();
String appYamlName;
if (environment.isStandard() || environment.isFlexCompat()) {
appYamlName = FlexibleFacetEditor.APP_YAML_FILE_NAME;
} else {
String moduleName = deploymentConfiguration.getModuleName();
if (StringUtils.isEmpty(moduleName)) {
callback.errorOccurred(
GctBundle.message("appengine.deployment.error.appyaml.notspecified"));
return;
}
AppEngineFlexibleFacet flexFacet =
AppEngineFlexibleFacet.getFacetByModuleName(moduleName, helper.getProject());
if (flexFacet == null) {
// This should not happen since staging already verified the file
callback.errorOccurred(GctBundle.message("appengine.deployment.error.appyaml.notfound"));
return;
} else {
appYamlName =
Paths.get(flexFacet.getConfiguration().getAppYamlPath()).getFileName().toString();
}
}
List<File> deployables =
APPENGINE_EXTRA_CONFIG_FILE_PATHS
.stream()
.map(configFilePath -> stagingDirectory.resolve(configFilePath).toFile())
.filter(
configFile -> deploymentConfiguration.isDeployAllConfigs() && configFile.exists())
.collect(Collectors.toList());
deployables.add(stagingDirectory.resolve(appYamlName).toFile());
configuration.setDeployables(deployables);
configuration.setProject(deploymentConfiguration.getCloudProjectName());
configuration.setPromote(deploymentConfiguration.isPromote());
// Only send stopPreviousVersion if the environment is AE flexible (since standard does not
// support stop), and if promote is true (since its invalid to stop the previous version without
// promoting).
if ((environment.isFlexible() || environment.isFlexCompat())
&& deploymentConfiguration.isPromote()) {
configuration.setStopPreviousVersion(deploymentConfiguration.isStopPreviousVersion());
}
if (!StringUtil.isEmpty(deploymentConfiguration.getVersion())) {
configuration.setVersion(deploymentConfiguration.getVersion());
}
ProcessExitListener deployExitListener = new DeployExitListener(rawDeployOutput);
CloudSdk sdk =
helper.createSdk(
loggingHandler,
deployStartListener,
line -> loggingHandler.print(line + "\n"),
rawDeployOutput::append,
deployExitListener);
// show a warning notification if the cloud sdk version is not supported
CloudSdkVersionNotifier.getInstance().notifyIfUnsupportedVersion();
CloudSdkAppEngineDeployment deployment = new CloudSdkAppEngineDeployment(sdk);
deployment.deploy(configuration);
}
示例12: execute
import com.google.cloud.tools.appengine.cloudsdk.process.ProcessStartListener; //导入依赖的package包/类
@Override
public void execute(ProcessStartListener startListener) {
UsageTrackerProvider.getInstance()
.trackEvent(GctTracking.APP_ENGINE_DEPLOY)
.addMetadata(GctTracking.METADATA_LABEL_KEY, isFlexCompat ? "flex-compat" : "standard")
.ping();
Path stagingDirectory;
AppEngineHelper helper = deploy.getHelper();
try {
stagingDirectory =
helper.createStagingDirectory(
deploy.getLoggingHandler(),
deploy.getDeploymentConfiguration().getCloudProjectName());
} catch (IOException ioe) {
deploy
.getCallback()
.errorOccurred(
GctBundle.message("appengine.deployment.error.creating.staging.directory"));
logger.error(ioe);
return;
}
try {
if (helper.stageCredentials(deploy.getDeploymentConfiguration().getGoogleUsername())
== null) {
deploy
.getCallback()
.errorOccurred(GctBundle.message("appengine.staging.credentials.error.message"));
return;
}
stageStandard.stage(stagingDirectory, startListener, deploy(stagingDirectory, startListener));
} catch (AppEngineJavaComponentsNotInstalledException ex) {
deploy
.getCallback()
.errorOccurred(
GctBundle.message("appengine.cloudsdk.java.components.missing")
+ "\n"
+ GctBundle.message("appengine.cloudsdk.java.components.howtoinstall"));
logger.warn(ex);
} catch (RuntimeException re) {
deploy
.getCallback()
.errorOccurred(
GctBundle.message("appengine.deployment.exception.during.staging")
+ "\n"
+ GctBundle.message("appengine.action.error.update.message"));
logger.error(re);
}
}
示例13: createSdk
import com.google.cloud.tools.appengine.cloudsdk.process.ProcessStartListener; //导入依赖的package包/类
/**
* Creates a {@link CloudSdk} object that is used in execution of various App Engine actions.
*
* @param loggingHandler logging messages will be output to this
* @param startListener the "callback" listener used for fetching the running process
* @param logListener the output listener for handling "normal" operation log messages
* @param outputListener the output listener for handling the output messages of the operation
* @param exitListener the listener for handling the completion of the operation
* @return the {@link CloudSdk} object used in executing the operation
*/
CloudSdk createSdk(
LoggingHandler loggingHandler,
ProcessStartListener startListener,
ProcessOutputLineListener logListener,
ProcessOutputLineListener outputListener,
ProcessExitListener exitListener);
示例14: execute
import com.google.cloud.tools.appengine.cloudsdk.process.ProcessStartListener; //导入依赖的package包/类
/**
* Executes an App Engine task.
*
* @param startListener a callback for retrieving the running process
*/
abstract void execute(ProcessStartListener startListener);