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


Java Marathon类代码示例

本文整理汇总了Java中mesosphere.marathon.client.Marathon的典型用法代码示例。如果您正苦于以下问题:Java Marathon类的具体用法?Java Marathon怎么用?Java Marathon使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: doUpdate

import mesosphere.marathon.client.Marathon; //导入依赖的package包/类
/**
 * Construct a Marathon client based on the provided credentialsId and execute an update for the configuration's
 * Marathon application.
 *
 * @param credentialsId A string ID for a credential within Jenkin's Credential store
 * @throws MarathonException thrown if the Marathon service has an error
 */
private void doUpdate(final String credentialsId) throws MarathonException {
    final Credentials credentials = MarathonBuilderUtils.getJenkinsCredentials(credentialsId, Credentials.class);

    Marathon client;

    if (credentials instanceof UsernamePasswordCredentials) {
        client = getMarathonClient((UsernamePasswordCredentials) credentials);
    } else if (credentials instanceof StringCredentials) {
        client = getMarathonClient((StringCredentials) credentials);
    } else {
        client = getMarathonClient();
    }

    if (client != null) {
        client.updateApp(getApp().getId(), getApp(), config.getForceUpdate());
    }
}
 
开发者ID:jenkinsci,项目名称:marathon-plugin,代码行数:25,代码来源:MarathonBuilderImpl.java

示例2: getMarathonClient

import mesosphere.marathon.client.Marathon; //导入依赖的package包/类
/**
 * Get a Marathon client with Authorization headers using the token within provided credentials. If the content of
 * credentials is JSON, this will use the "jenkins_token" field; if the content is just a string, that will be
 * used as the token value.
 *
 * @param credentials String credentials
 * @return Marathon client with token in auth header
 */
private Marathon getMarathonClient(StringCredentials credentials) {
    String token;

    try {
        final JSONObject json = JSONObject.fromObject(credentials.getSecret().getPlainText());
        if (json.has("jenkins_token")) {
            token = json.getString("jenkins_token");
        } else {
            token = "";
        }
    } catch (JSONException jse) {
        token = credentials.getSecret().getPlainText();
    }

    if (StringUtils.isNotEmpty(token)) {
        return MarathonClient
                .getInstanceWithTokenAuth(getURL(), token);
    }

    return getMarathonClient();
}
 
开发者ID:jenkinsci,项目名称:marathon-plugin,代码行数:30,代码来源:MarathonBuilderImpl.java

示例3: createTestEnvironment

import mesosphere.marathon.client.Marathon; //导入依赖的package包/类
public static MarathonTestEnvironment createTestEnvironment(Strategy strategy) throws ResourceConfigException, ResourceException, IOException, EnvironmentConfigException {
    Map<String, String> environmentVariables = TestEnvironmentUtil.loadEnvironmentVariables(
            MARATHON_TOKEN_ENV,
            MARATHON_URL_ENV
    );

    EnvironmentConfig environmentConfig = createEnvironmentConfig(environmentVariables, strategy);

    // Replace the token.
    TokenResource tokenResource = new TokenResource(environmentConfig);
    String apiToken = tokenResource.retrieveAuthenticationToken(environmentVariables.get(MARATHON_TOKEN_ENV));
    environmentConfig.getAuthConfig().setToken(apiToken);

    ClientFactory clientFactory = createClientFactory(environmentConfig);

    Marathon marathonClient = createMarathonClient(environmentConfig);
    return new MarathonTestEnvironment(clientFactory, environmentConfig, marathonClient);
}
 
开发者ID:qaware,项目名称:gradle-cloud-deployer,代码行数:19,代码来源:MarathonTestEnvironmentUtil.java

示例4: getAppTasks

import mesosphere.marathon.client.Marathon; //导入依赖的package包/类
private void getAppTasks(Marathon marathon, App app) throws MojoExecutionException {
    try {
        final GetAppTasksResponse getAppTasksResponse = marathon.getAppTasks(app.getId());
        int taskCount = 0;
        for (final Task task : getAppTasksResponse.getTasks()) {
            final String hostPropertyName = propertyPrefix + "host" + taskCount;
            project.getProperties().put(hostPropertyName, task.getHost());
            getLog().info("Setting " + hostPropertyName + " = " + task.getHost());
            int portCount = 0;
            for (final Integer port : task.getPorts()) {
                final String portPropertyName = propertyPrefix + "port"
                        + taskCount + "-" + portCount;
                project.getProperties().put(portPropertyName, String.valueOf(port));
                getLog().info("Setting " + portPropertyName + " = " + port);
                portCount++;
            }
            taskCount++;
        }
    } catch (Exception deleteAppException) {
        throw new MojoExecutionException("Failed to get tasks for Marathon instance "
                + marathonHost, deleteAppException);
    }
}
 
开发者ID:holidaycheck,项目名称:marathon-maven-plugin,代码行数:24,代码来源:AppTasksMojo.java

示例5: execute

import mesosphere.marathon.client.Marathon; //导入依赖的package包/类
@Override
public void execute() throws MojoExecutionException, MojoFailureException {
    final Marathon marathon = MarathonClient.getInstance(marathonHost);
    App app = readApp(finalMarathonConfigFile);
    getLog().info("deploying Marathon config for " + app.getId()
            + " from " + finalMarathonConfigFile + " to " + marathonHost);
    if (appExists(marathon, app.getId())) {
        getLog().info(app.getId() + " already exists - will be updated");
        updateApp(marathon, app);
    } else {
        getLog().info(app.getId() + " does not exist yet - will be created");
        app = createApp(marathon, app);
    }

    if (waitForDeploymentFinished) {
        try {
            waitForApp(marathon, app);
        } catch (MarathonException e) {
            throw new MojoExecutionException("error waiting for app", e);
        }
    }
}
 
开发者ID:holidaycheck,项目名称:marathon-maven-plugin,代码行数:23,代码来源:DeployMojo.java

示例6: build

import mesosphere.marathon.client.Marathon; //导入依赖的package包/类
/**
 * Generate a new Marathon client.
 * 
 * @param marathonProperties
 *          the properties containing the client information
 * @return the new client
 */
@Override
public Marathon build(MarathonProperties marathonProperties) {
  LOG.info("Generating Marathon client with parameters: {}", marathonProperties);

  return Feign
      .builder()
      .encoder(new GsonEncoder(ModelUtils.GSON))
      .decoder(new GsonDecoder(ModelUtils.GSON))
      .logger(new Slf4jLogger(Marathon.class))
      .logLevel(Level.FULL)
      .errorDecoder(new DeserializingMarathonErrorDecoder())
      .requestInterceptor(new BasicAuthRequestInterceptor(
          marathonProperties.getUsername(), marathonProperties.getPassword()))
      .requestInterceptor(template -> {
        template.header(HttpHeaders.ACCEPT, "application/json");
        template.header(HttpHeaders.CONTENT_TYPE, "application/json");
      })
      .target(Marathon.class, marathonProperties.getUrl().toString());
}
 
开发者ID:indigo-dc,项目名称:orchestrator,代码行数:27,代码来源:MarathonClientFactory.java

示例7: getPolulatedGroup

import mesosphere.marathon.client.Marathon; //导入依赖的package包/类
@Deprecated
// TODO remove it and use just getGroup with embed params (requires marathon client version >
// 6.0.0)
private Group getPolulatedGroup(Deployment deployment, String groupId) throws MarathonException {
  final Marathon client = getMarathonClient(deployment);
  Group group = client.getGroup(groupId);

  Collection<App> apps = Optional.ofNullable(group.getApps()).orElseGet(Collections::emptyList);

  List<App> completeInfoApps = new ArrayList<>();
  for (App app : apps) {
    completeInfoApps.add(client.getApp(app.getId()).getApp());
  }
  apps = completeInfoApps;

  group.setApps(apps);
  return group;
}
 
开发者ID:indigo-dc,项目名称:orchestrator,代码行数:19,代码来源:MarathonServiceImpl.java

示例8: getInstance

import mesosphere.marathon.client.Marathon; //导入依赖的package包/类
/**
 * The generalized version of the method that allows more in-depth customizations via
 * {@link RequestInterceptor}s.
 *
 * @param endpoint
 * 		URL of Marathon
 */
private static Marathon getInstance(String endpoint, RequestInterceptor... interceptors) {
	Builder b = Feign.builder()
			.encoder(new GsonEncoder(ModelUtils.GSON))
			.decoder(new GsonDecoder(ModelUtils.GSON))
			.errorDecoder(new MarathonErrorDecoder());

	if (interceptors!=null)
		b.requestInterceptors(asList(interceptors));

	b.requestInterceptor(new MarathonHeadersInterceptor());

	return b.target(Marathon.class, endpoint);
}
 
开发者ID:pikselpalette,项目名称:gocd-elastic-agent-marathon,代码行数:21,代码来源:MarathonClient.java

示例9: marathonClient

import mesosphere.marathon.client.Marathon; //导入依赖的package包/类
@Bean
@ConditionalOnMissingBean
public Marathon marathonClient(MarathonProperties properties) {
    return new RibbonMarathonClient.Builder(properties.getEndpoint())
            .withListOfServers(properties.getListOfServers())
            .withToken(properties.getToken())
            .withUsername(properties.getUsername())
            .withPassword(properties.getPassword())
            .build();
}
 
开发者ID:aatarasoff,项目名称:spring-cloud-marathon,代码行数:11,代码来源:MarathonAutoConfiguration.java

示例10: MarathonServerList

import mesosphere.marathon.client.Marathon; //导入依赖的package包/类
public MarathonServerList(Marathon client, MarathonDiscoveryProperties properties) {
    this.client = client;
    this.properties = properties;
    this.queryMap = new HashMap<>();
    this.ignoreServiceId = false;
    metaDataFilter = new HashMap<>();
}
 
开发者ID:aatarasoff,项目名称:spring-cloud-marathon,代码行数:8,代码来源:MarathonServerList.java

示例11: MarathonRibbonClientConfiguration

import mesosphere.marathon.client.Marathon; //导入依赖的package包/类
@Autowired
public MarathonRibbonClientConfiguration(Marathon client,
                                         IClientConfig clientConfig,
                                         MarathonDiscoveryProperties properties) {
    this.client = client;
    this.clientConfig = clientConfig;
    this.properties = properties;
}
 
开发者ID:aatarasoff,项目名称:spring-cloud-marathon,代码行数:9,代码来源:MarathonRibbonClientConfiguration.java

示例12: marathonClient

import mesosphere.marathon.client.Marathon; //导入依赖的package包/类
@Bean
public Marathon marathonClient(MarathonProperties properties) throws MarathonException {
    Marathon client = mock(Marathon.class);

    when(client.getServerInfo()).thenReturn(new GetServerInfoResponse());

    GetAppsResponse appsResponse = new GetAppsResponse();
    App app = new App();
    app.setId("test-app");
    appsResponse.setApps(Collections.singletonList(app));
    when(client.getApps()).thenReturn(appsResponse);

    return client;
}
 
开发者ID:aatarasoff,项目名称:spring-cloud-marathon,代码行数:15,代码来源:MarathonEndpointTests.java

示例13: marathon

import mesosphere.marathon.client.Marathon; //导入依赖的package包/类
@Bean
@RefreshScope
public Marathon marathon(MarathonAppDeployerProperties marathonProperties, DcosClusterProperties dcosClusterProperties) {
	if (StringUtils.hasText(dcosClusterProperties.getAuthorizationToken())) {
		return MarathonClient.getInstance(marathonProperties.getApiEndpoint(),
				new DcosHeadersInterceptor(dcosClusterProperties.getAuthorizationToken()));
	}
	else {
		return MarathonClient.getInstance(marathonProperties.getApiEndpoint());
	}
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-deployer-mesos,代码行数:12,代码来源:MesosAutoConfiguration.java

示例14: marathon

import mesosphere.marathon.client.Marathon; //导入依赖的package包/类
@Bean
public Marathon marathon(MarathonAppDeployerProperties marathonProperties,
                         DcosClusterProperties dcosClusterProperties) {
	if (StringUtils.hasText(dcosClusterProperties.getAuthorizationToken())) {
		return MarathonClient.getInstance(marathonProperties.getApiEndpoint(),
				new DcosHeadersInterceptor(dcosClusterProperties.getAuthorizationToken()));
	}
	else {
		return MarathonClient.getInstance(marathonProperties.getApiEndpoint());
	}
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-deployer-mesos,代码行数:12,代码来源:MarathonTestSupport.java

示例15: getInstance

import mesosphere.marathon.client.Marathon; //导入依赖的package包/类
private static Marathon getInstance(String endpoint, RequestInterceptor... interceptors) {
    Feign.Builder b = Feign.builder().client(LoginClient.getClientHostVerificationDisabled())
            .logger(new Logger.ErrorLogger())
            .logLevel(Logger.Level.BASIC)
            .encoder(new GsonEncoder(ModelUtils.GSON))
            .decoder(new GsonDecoder(ModelUtils.GSON))
            .errorDecoder(new MarathonErrorDecoder())
            //max wait period = 5 seconds ; max attempts = 5
            .retryer(new Retryer.Default(SECONDS.toMillis(1), SECONDS.toMillis(5), 5));
    if (interceptors != null) {
        b.requestInterceptors(asList(interceptors));
    }
    b.requestInterceptor(new MarathonHeadersInterceptor());
    return b.target(Marathon.class, endpoint);
}
 
开发者ID:pravega,项目名称:pravega,代码行数:16,代码来源:AuthEnabledMarathonClient.java


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