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


Java EnvironmentImpl类代码示例

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


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

示例1: setUp

import org.eclipse.che.api.workspace.server.model.impl.EnvironmentImpl; //导入依赖的package包/类
@BeforeMethod
public void setUp() throws Exception {
  devExtendedMachine = new ExtendedMachineImpl();
  extendedMachine = new ExtendedMachineImpl();
  environment = new EnvironmentImpl();
  cheService = new CheServiceImpl();
  CheServiceImpl devCheService = new CheServiceImpl();
  internalEnv = new CheServicesEnvironmentImpl();

  provisioner =
      new CodenvyInContainerInfrastructureProvisioner(
          agentConfigApplier, SYNC_KEY, TEST_PROJECTS_FOLDER);

  Map<String, ExtendedMachineImpl> extendedMachines = new HashMap<>();
  extendedMachines.put(NON_DEV_MACHINE_NAME, extendedMachine);
  extendedMachines.put(DEV_MACHINE_NAME, devExtendedMachine);
  environment.setMachines(extendedMachines);
  Map<String, CheServiceImpl> services = new HashMap<>();
  services.put(NON_DEV_MACHINE_NAME, cheService);
  services.put(DEV_MACHINE_NAME, devCheService);
  internalEnv.setServices(services);
  devExtendedMachine.setAgents(
      asList("org.eclipse.che.exec", "org.eclipse.che.terminal", "org.eclipse.che.ws-agent"));
  extendedMachine.setAgents(
      asList("org.eclipse.che.ws-agent2", "not.che.ws-agent", "org.eclipse.che.terminal"));
}
 
开发者ID:codenvy,项目名称:codenvy,代码行数:27,代码来源:CodenvyInContainerInfrastructureProvisionerTest.java

示例2: setUp

import org.eclipse.che.api.workspace.server.model.impl.EnvironmentImpl; //导入依赖的package包/类
@BeforeMethod
public void setUp() throws Exception {
  scheduler =
      spy(
          new WorkspaceFsBackupScheduler(
              Collections.singletonMap(ENV_TYPE, backupManager),
              workspaceRuntimes,
              BACKUP_TIMEOUT,
              workspaceManager));

  EnvironmentImpl environment = new EnvironmentImpl();
  EnvironmentRecipeImpl environmentRecipe = new EnvironmentRecipeImpl();
  environmentRecipe.setType(ENV_TYPE);
  environment.setRecipe(environmentRecipe);
  WorkspaceConfigImpl workspaceConfig = new WorkspaceConfigImpl();
  workspaceConfig.setEnvironments(Collections.singletonMap(ACTIVE_ENV, environment));
  this.workspaceConfig = spy(workspaceConfig);

  ids = new LinkedHashSet<>();
  addWorkspace(WORKSPACE_ID_1);
  addWorkspace(WORKSPACE_ID_2);
  when(workspaceRuntimes.getRuntimesIds()).thenReturn(ids);
}
 
开发者ID:codenvy,项目名称:codenvy,代码行数:24,代码来源:WorkspaceFsBackupSchedulerTest.java

示例3: createWorkspace

import org.eclipse.che.api.workspace.server.model.impl.EnvironmentImpl; //导入依赖的package包/类
/** Creates users workspace object based on the status and machines RAM. */
private static WorkspaceImpl createWorkspace(WorkspaceStatus status, Integer... machineRams) {
  final Map<String, MachineImpl> machines = new HashMap<>(machineRams.length - 1);
  final Map<String, MachineConfigImpl> machineConfigs = new HashMap<>(machineRams.length - 1);
  byte i = 1;
  for (Integer machineRam : machineRams) {
    final String machineName = "machine_" + i++;
    machines.put(machineName, createMachine(machineRam));
    machineConfigs.put(machineName, createMachineConfig(machineRam));
  }
  return WorkspaceImpl.builder()
      .setConfig(
          WorkspaceConfigImpl.builder()
              .setEnvironments(
                  ImmutableBiMap.of(ACTIVE_ENV_NAME, new EnvironmentImpl(null, machineConfigs)))
              .build())
      .setRuntime(new RuntimeImpl(ACTIVE_ENV_NAME, machines, null))
      .setStatus(status)
      .build();
}
 
开发者ID:eclipse,项目名称:che,代码行数:21,代码来源:RamResourceUsageTrackerTest.java

示例4: createEnv

import org.eclipse.che.api.workspace.server.model.impl.EnvironmentImpl; //导入依赖的package包/类
public static EnvironmentImpl createEnv() {
  final RecipeImpl newRecipe = new RecipeImpl();
  newRecipe.setLocation("new-location");
  newRecipe.setType("new-type");
  newRecipe.setContentType("new-content-type");
  newRecipe.setContent("new-content");

  final MachineConfigImpl newMachine = new MachineConfigImpl();
  final ServerConfigImpl serverConf1 =
      new ServerConfigImpl("2265", "http", "/path1", singletonMap("key", "value"));
  final ServerConfigImpl serverConf2 =
      new ServerConfigImpl("2266", "ftp", "/path2", singletonMap("key", "value"));
  newMachine.setServers(ImmutableMap.of("ref1", serverConf1, "ref2", serverConf2));
  newMachine.setInstallers(ImmutableList.of("agent5", "agent4"));
  newMachine.setAttributes(singletonMap("att1", "val"));
  newMachine.setEnv(singletonMap("CHE_ENV", "value"));

  final EnvironmentImpl newEnv = new EnvironmentImpl();
  newEnv.setMachines(ImmutableMap.of("new-machine", newMachine));
  newEnv.setRecipe(newRecipe);
  return newEnv;
}
 
开发者ID:eclipse,项目名称:che,代码行数:23,代码来源:TestObjectsFactory.java

示例5: createEnvDto

import org.eclipse.che.api.workspace.server.model.impl.EnvironmentImpl; //导入依赖的package包/类
private static EnvironmentDto createEnvDto() {
  final RecipeImpl environmentRecipe = new RecipeImpl();
  environmentRecipe.setType("type");
  environmentRecipe.setContent("content");
  environmentRecipe.setContentType("compose");
  environmentRecipe.setLocation("location");
  final EnvironmentImpl env = new EnvironmentImpl();
  final MachineConfigImpl extendedMachine = new MachineConfigImpl();
  extendedMachine.setInstallers(singletonList("agent"));
  extendedMachine.setAttributes(singletonMap("att1", "value"));
  extendedMachine.setServers(
      singletonMap(
          "agent", new ServerConfigImpl("5555", "https", "path", singletonMap("key", "value"))));
  env.setRecipe(environmentRecipe);
  env.setMachines(singletonMap("machine1", extendedMachine));
  return org.eclipse.che.api.workspace.server.DtoConverter.asDto(env);
}
 
开发者ID:eclipse,项目名称:che,代码行数:18,代码来源:FactoryServiceTest.java

示例6: shouldDeleteEnvironment

import org.eclipse.che.api.workspace.server.model.impl.EnvironmentImpl; //导入依赖的package包/类
@Test
public void shouldDeleteEnvironment() throws Exception {
  final WorkspaceImpl workspace = createWorkspace(createConfigDto());
  when(wsManager.getWorkspace(workspace.getId())).thenReturn(workspace);
  Map.Entry<String, EnvironmentImpl> envEntry =
      workspace.getConfig().getEnvironments().entrySet().iterator().next();

  final Response response =
      given()
          .auth()
          .basic(ADMIN_USER_NAME, ADMIN_USER_PASSWORD)
          .when()
          .delete(
              SECURE_PATH
                  + "/workspace/"
                  + workspace.getId()
                  + "/environment/"
                  + envEntry.getKey());

  assertEquals(response.getStatusCode(), 204);
  verify(wsManager).updateWorkspace(any(), any());
}
 
开发者ID:eclipse,项目名称:che,代码行数:23,代码来源:WorkspaceServiceTest.java

示例7: shouldUseRetrievedRecipeWhileInternalEnvironmentCreation

import org.eclipse.che.api.workspace.server.model.impl.EnvironmentImpl; //导入依赖的package包/类
@Test
public void shouldUseRetrievedRecipeWhileInternalEnvironmentCreation() throws Exception {
  // given
  RecipeImpl recipe = new RecipeImpl("type", "contentType", "content", "location");
  InternalRecipe retrievedRecipe = mock(InternalRecipe.class);
  doReturn(retrievedRecipe).when(recipeRetriever).getRecipe(any());

  EnvironmentImpl env = new EnvironmentImpl(recipe, null);

  // when
  environmentFactory.create(env);

  // then
  verify(recipeRetriever).getRecipe(recipe);
  verify(environmentFactory).doCreate(eq(retrievedRecipe), any(), any());
}
 
开发者ID:eclipse,项目名称:che,代码行数:17,代码来源:InternalEnvironmentFactoryTest.java

示例8: shouldUseRetrievedInstallerWhileInternalEnvironmentCreation

import org.eclipse.che.api.workspace.server.model.impl.EnvironmentImpl; //导入依赖的package包/类
@Test
public void shouldUseRetrievedInstallerWhileInternalEnvironmentCreation() throws Exception {
  // given
  List<Installer> installersToRetrieve = singletonList(mock(Installer.class));
  doReturn(installersToRetrieve).when(installerRegistry).getOrderedInstallers(anyList());

  List<String> sourceInstallers = singletonList("ws-agent");
  MachineConfigImpl machineConfig = new MachineConfigImpl().withInstallers(sourceInstallers);
  EnvironmentImpl env = new EnvironmentImpl(null, ImmutableMap.of("machine", machineConfig));

  // when
  environmentFactory.create(env);

  // then
  verify(installerRegistry).getOrderedInstallers(sourceInstallers);
  verify(environmentFactory).doCreate(any(), machinesCaptor.capture(), any());
  Map<String, InternalMachineConfig> internalMachines = machinesCaptor.getValue();
  assertEquals(internalMachines.get("machine").getInstallers(), installersToRetrieve);
}
 
开发者ID:eclipse,项目名称:che,代码行数:20,代码来源:InternalEnvironmentFactoryTest.java

示例9: shouldUseNormalizedServersWhileInternalEnvironmentCreation

import org.eclipse.che.api.workspace.server.model.impl.EnvironmentImpl; //导入依赖的package包/类
@Test
public void shouldUseNormalizedServersWhileInternalEnvironmentCreation() throws Exception {
  // given
  ServerConfigImpl server =
      new ServerConfigImpl("8080", "http", "/api", singletonMap("key", "value"));

  Map<String, ServerConfig> normalizedServers =
      ImmutableMap.of("server", mock(ServerConfig.class));
  doReturn(normalizedServers).when(environmentFactory).normalizeServers(any());

  ImmutableMap<String, ServerConfigImpl> sourceServers = ImmutableMap.of("server", server);
  MachineConfigImpl machineConfig = new MachineConfigImpl(null, sourceServers, null, null, null);

  EnvironmentImpl env = new EnvironmentImpl(null, ImmutableMap.of("machine", machineConfig));

  // when
  environmentFactory.create(env);

  // then
  verify(environmentFactory).normalizeServers(sourceServers);
  verify(environmentFactory).doCreate(any(), machinesCaptor.capture(), any());
  Map<String, InternalMachineConfig> internalMachines = machinesCaptor.getValue();
  assertEquals(internalMachines.get("machine").getServers(), normalizedServers);
}
 
开发者ID:eclipse,项目名称:che,代码行数:25,代码来源:InternalEnvironmentFactoryTest.java

示例10: mockWorkspace

import org.eclipse.che.api.workspace.server.model.impl.EnvironmentImpl; //导入依赖的package包/类
private WorkspaceImpl mockWorkspace(RuntimeIdentity identity)
    throws NotFoundException, ServerException {
  EnvironmentImpl environment = mock(EnvironmentImpl.class);
  when(environment.getRecipe())
      .thenReturn(new RecipeImpl(TEST_ENVIRONMENT_TYPE, "contentType1", "content1", null));

  WorkspaceConfigImpl config = mock(WorkspaceConfigImpl.class);
  when(config.getEnvironments()).thenReturn(ImmutableMap.of(identity.getEnvName(), environment));

  WorkspaceImpl workspace = mock(WorkspaceImpl.class);
  when(workspace.getConfig()).thenReturn(config);
  when(workspace.getId()).thenReturn(identity.getWorkspaceId());
  when(workspace.getAttributes()).thenReturn(new HashMap<>());

  when(workspaceDao.get(identity.getWorkspaceId())).thenReturn(workspace);

  return workspace;
}
 
开发者ID:eclipse,项目名称:che,代码行数:19,代码来源:WorkspaceRuntimesTest.java

示例11: createConfig

import org.eclipse.che.api.workspace.server.model.impl.EnvironmentImpl; //导入依赖的package包/类
private static WorkspaceConfigImpl createConfig() {
  MachineConfigImpl machineConfig =
      new MachineConfigImpl(
          singletonList("org.eclipse.che.ws-agent"),
          null,
          singletonMap("CHE_ENV", "value"),
          singletonMap(MEMORY_LIMIT_ATTRIBUTE, "10000"),
          emptyMap());
  EnvironmentImpl environment =
      new EnvironmentImpl(
          new RecipeImpl("type", "contentType", "content", null),
          singletonMap("dev-machine", machineConfig));
  return WorkspaceConfigImpl.builder()
      .setName("dev-workspace")
      .setDefaultEnv("dev-env")
      .setEnvironments(singletonMap("dev-env", environment))
      .build();
}
 
开发者ID:eclipse,项目名称:che,代码行数:19,代码来源:WorkspaceManagerTest.java

示例12: configure

import org.eclipse.che.api.workspace.server.model.impl.EnvironmentImpl; //导入依赖的package包/类
@Override
protected void configure() {
  H2DBTestServer server = H2DBTestServer.startDefault();
  install(
      new PersistTestModuleBuilder()
          .setDriver(Driver.class)
          .runningOn(server)
          .addEntityClasses(
              OrganizationImpl.class,
              AccountImpl.class,
              WorkspaceImpl.class,
              WorkspaceConfigImpl.class,
              ProjectConfigImpl.class,
              EnvironmentImpl.class,
              ExtendedMachineImpl.class,
              CommandImpl.class,
              SourceStorageImpl.class,
              ServerConf2Impl.class,
              SnapshotImpl.class,
              InviteImpl.class)
          .addEntityClass(
              "org.eclipse.che.api.workspace.server.model.impl.ProjectConfigImpl$Attribute")
          .setExceptionHandler(H2ExceptionHandler.class)
          .build());
  bind(DBInitializer.class).asEagerSingleton();
  bind(SchemaInitializer.class)
      .toInstance(
          new FlywaySchemaInitializer(server.getDataSource(), "che-schema", "codenvy-schema"));
  bind(TckResourcesCleaner.class).toInstance(new H2JpaCleaner(server));

  bind(new TypeLiteral<TckRepository<InviteImpl>>() {})
      .toInstance(new JpaTckRepository<>(InviteImpl.class));
  bind(new TypeLiteral<TckRepository<OrganizationImpl>>() {})
      .toInstance(new JpaTckRepository<>(OrganizationImpl.class));
  bind(new TypeLiteral<TckRepository<WorkspaceImpl>>() {})
      .toInstance(new JpaTckRepository<>(WorkspaceImpl.class));

  bind(InviteDao.class).to(JpaInviteDao.class);
}
 
开发者ID:codenvy,项目名称:codenvy,代码行数:40,代码来源:InviteJpaTckModule.java

示例13: provision

import org.eclipse.che.api.workspace.server.model.impl.EnvironmentImpl; //导入依赖的package包/类
@Override
public void provision(EnvironmentImpl envConfig, CheServicesEnvironmentImpl internalEnv)
    throws EnvironmentException {
  String devMachineName = getDevMachineName(envConfig);
  if (devMachineName == null) {
    throw new EnvironmentException("ws-machine is not found on agents applying");
  }
  CheServiceImpl devMachine = internalEnv.getServices().get(devMachineName);

  // dev-machine-only configuration
  HashMap<String, String> environmentVars = new HashMap<>(devMachine.getEnvironment());
  environmentVars.put(SYNC_KEY_ENV_VAR_NAME, pubSyncKey);
  // TODO is not used, but ws-agent doesn't start without it
  environmentVars.put(
      CheBootstrap.CHE_LOCAL_CONF_DIR, DockerExtConfBindingProvider.EXT_CHE_LOCAL_CONF_DIR);
  devMachine.setEnvironment(environmentVars);

  ExtendedMachineImpl extendedMachine = envConfig.getMachines().get(devMachineName);
  List<String> agents = new ArrayList<>(extendedMachine.getAgents());
  agents.add(agents.indexOf("org.eclipse.che.ws-agent"), "com.codenvy.rsync_in_machine");
  extendedMachine.setAgents(agents);

  List<String> volumes = new ArrayList<>(devMachine.getVolumes());
  volumes.add(projectFolder);
  devMachine.setVolumes(volumes);

  for (CheServiceImpl service : internalEnv.getServices().values()) {
    volumes = new ArrayList<>(service.getVolumes());
    volumes.addAll(
        SNAPSHOT_EXCLUDED_DIRECTORIES); // creates volume for each directory to exclude from a
    // snapshot
    service.setVolumes(volumes);
  }

  super.provision(envConfig, internalEnv);
}
 
开发者ID:codenvy,项目名称:codenvy,代码行数:37,代码来源:CodenvyInContainerInfrastructureProvisioner.java

示例14: getUsedResource

import org.eclipse.che.api.workspace.server.model.impl.EnvironmentImpl; //导入依赖的package包/类
@Override
public Optional<Resource> getUsedResource(String accountId)
    throws NotFoundException, ServerException {
  final Account account = accountManager.getById(accountId);
  List<WorkspaceImpl> activeWorkspaces =
      Pages.stream(
              (maxItems, skipCount) ->
                  workspaceManagerProvider
                      .get()
                      .getByNamespace(account.getName(), true, maxItems, skipCount))
          .filter(ws -> STOPPED != ws.getStatus())
          .collect(Collectors.toList());
  long currentlyUsedRamMB = 0;
  for (WorkspaceImpl activeWorkspace : activeWorkspaces) {
    if (WorkspaceStatus.STARTING.equals(activeWorkspace.getStatus())) {
      // starting workspace may not have all machine in runtime
      // it is need to calculate ram from environment config
      final EnvironmentImpl startingEnvironment =
          activeWorkspace
              .getConfig()
              .getEnvironments()
              .get(activeWorkspace.getRuntime().getActiveEnv());
      currentlyUsedRamMB += environmentRamCalculator.calculate(startingEnvironment);
    } else {
      currentlyUsedRamMB += environmentRamCalculator.calculate(activeWorkspace.getRuntime());
    }
  }

  if (currentlyUsedRamMB > 0) {
    return Optional.of(
        new ResourceImpl(RamResourceType.ID, currentlyUsedRamMB, RamResourceType.UNIT));
  } else {
    return Optional.empty();
  }
}
 
开发者ID:eclipse,项目名称:che,代码行数:36,代码来源:RamResourceUsageTracker.java

示例15: createEnvironment

import org.eclipse.che.api.workspace.server.model.impl.EnvironmentImpl; //导入依赖的package包/类
public static EnvironmentImpl createEnvironment(String devMachineRam, String... machineRams)
    throws Exception {
  return null; /*
               Map<String, ExtendedMachineImpl> machines = new HashMap<>();
               machines.put(
                   "dev-machine",
                   new ExtendedMachineImpl(
                       singletonList("org.eclipse.che.ws-agent"),
                       emptyMap(),
                       singletonMap("memoryLimitBytes", Long.toString(Size.parseSize(devMachineRam)))));
               HashMap<String, ComposeServiceImpl> services = new HashMap<>(1 + machineRams.length);
               services.put("dev-machine", createService());
               for (int i = 0; i < machineRams.length; i++) {
                 services.put("machine" + i, createService());
                 // null is allowed to reproduce situation with default RAM size
                 if (machineRams[i] != null) {
                   machines.put(
                       "machine" + i,
                       new ExtendedMachineImpl(
                           null,
                           null,
                           singletonMap("memoryLimitBytes", Long.toString(Size.parseSize(machineRams[i])))));
                 }
               }
               ComposeEnvironment composeEnvironment = new ComposeEnvironment();
               composeEnvironment.setServices(services);
               String yaml = YAML_PARSER.writeValueAsString(composeEnvironment);
               EnvironmentRecipeImpl recipe =
                   new EnvironmentRecipeImpl("compose", "application/x-yaml", yaml, null);

               return new EnvironmentImpl(recipe, machines);*/
}
 
开发者ID:eclipse,项目名称:che,代码行数:33,代码来源:TestObjects.java


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