当前位置: 首页>>代码示例>>Java>>正文


Java StopConfiguration类代码示例

本文整理汇总了Java中com.google.cloud.tools.appengine.api.devserver.StopConfiguration的典型用法代码示例。如果您正苦于以下问题:Java StopConfiguration类的具体用法?Java StopConfiguration怎么用?Java StopConfiguration使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


StopConfiguration类属于com.google.cloud.tools.appengine.api.devserver包,在下文中一共展示了StopConfiguration类的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getStopConfiguration

import com.google.cloud.tools.appengine.api.devserver.StopConfiguration; //导入依赖的package包/类
/** Return a stop configuration based on serverVersion. */
public StopConfiguration getStopConfiguration(RunExtension run) {

  String serverVersion = run.getServerVersion();
  validator.validateServerVersion(serverVersion);

  DefaultStopConfiguration stop = new DefaultStopConfiguration();

  switch (serverVersion) {
    case V1:
      stop.setAdminHost(run.getHost());
      stop.setAdminPort(run.getPort());
      return stop;
    case V2:
      stop.setAdminHost(run.getAdminHost());
      stop.setAdminPort(run.getAdminPort());
      return stop;
    default:
      throw new AssertionError("Unexpected serverVersion " + run.getServerVersion());
  }
}
 
开发者ID:GoogleCloudPlatform,项目名称:app-gradle-plugin,代码行数:22,代码来源:DevAppServerHelper.java

示例2: stop

import com.google.cloud.tools.appengine.api.devserver.StopConfiguration; //导入依赖的package包/类
/** Stops the local development server. */
@Override
public void stop(StopConfiguration config) throws AppEngineException {
  Preconditions.checkNotNull(config);

  try {
    URL adminServerUrl =
        new URL(
            "http",
            config.getAdminHost() != null ? config.getAdminHost() : DEFAULT_ADMIN_HOST,
            config.getAdminPort() != null ? config.getAdminPort() : DEFAULT_ADMIN_PORT,
            "/quit");
    HttpURLConnection connection = (HttpURLConnection) adminServerUrl.openConnection();

    connection.setReadTimeout(4000);
    connection.connect();
    connection.disconnect();
    int responseCode = connection.getResponseCode();
    if (responseCode < 200 || responseCode > 299) {
      throw new AppEngineException(
          "The development server responded with " + connection.getResponseMessage() + ".");
    }
  } catch (IOException e) {
    throw new AppEngineException(e);
  }
}
 
开发者ID:GoogleCloudPlatform,项目名称:appengine-plugins-core,代码行数:27,代码来源:CloudSdkAppEngineDevServer2.java

示例3: getStopConfiguration_v1

import com.google.cloud.tools.appengine.api.devserver.StopConfiguration; //导入依赖的package包/类
@Test
public void getStopConfiguration_v1() {
  when(run.getServerVersion()).thenReturn("1");
  when(run.getHost()).thenReturn("v1.com");
  when(run.getPort()).thenReturn(1234);

  StopConfiguration config = helper.getStopConfiguration(run);
  Assert.assertEquals("v1.com", config.getAdminHost());
  Assert.assertEquals(new Integer(1234), config.getAdminPort());

  verify(validator, times(1)).validateServerVersion(run.getServerVersion());
}
 
开发者ID:GoogleCloudPlatform,项目名称:app-gradle-plugin,代码行数:13,代码来源:DevAppServerHelperTest.java

示例4: getStopConfiguration_v2

import com.google.cloud.tools.appengine.api.devserver.StopConfiguration; //导入依赖的package包/类
@Test
public void getStopConfiguration_v2() {
  when(run.getServerVersion()).thenReturn("2-alpha");
  when(run.getAdminHost()).thenReturn("v2.com");
  when(run.getAdminPort()).thenReturn(4321);

  StopConfiguration config = helper.getStopConfiguration(run);
  Assert.assertEquals("v2.com", config.getAdminHost());
  Assert.assertEquals(new Integer(4321), config.getAdminPort());

  verify(validator, times(1)).validateServerVersion(run.getServerVersion());
}
 
开发者ID:GoogleCloudPlatform,项目名称:app-gradle-plugin,代码行数:13,代码来源:DevAppServerHelperTest.java

示例5: stop

import com.google.cloud.tools.appengine.api.devserver.StopConfiguration; //导入依赖的package包/类
/** Stops the local development server. */
@Override
public void stop(StopConfiguration configuration) throws AppEngineException {
  Preconditions.checkNotNull(configuration);
  HttpURLConnection connection = null;
  String adminHost =
      configuration.getAdminHost() != null ? configuration.getAdminHost() : DEFAULT_HOST;
  int adminPort =
      configuration.getAdminPort() != null ? configuration.getAdminPort() : DEFAULT_PORT;
  URL adminServerUrl = null;
  try {
    adminServerUrl = new URL("http", adminHost, adminPort, "/_ah/admin/quit");
    connection = (HttpURLConnection) adminServerUrl.openConnection();
    connection.setDoOutput(true);
    connection.setDoInput(true);
    connection.setRequestMethod("POST");
    connection.getOutputStream().write('\n');
    connection.disconnect();
    int responseCode = connection.getResponseCode();
    if (responseCode < 200 || responseCode > 299) {
      throw new AppEngineException(
          adminServerUrl + " responded with " + connection.getResponseMessage() + ".");
    }
  } catch (IOException ex) {
    throw new AppEngineException("Error connecting to " + adminServerUrl, ex);
  } finally {
    if (connection != null) {
      try {
        connection.getInputStream().close();
      } catch (IOException ignore) {
        // ignored
      }
    }
  }
}
 
开发者ID:GoogleCloudPlatform,项目名称:appengine-plugins-core,代码行数:36,代码来源:CloudSdkAppEngineDevServer1.java


注:本文中的com.google.cloud.tools.appengine.api.devserver.StopConfiguration类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。