本文整理汇总了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"));
}
示例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);
}
示例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();
}
示例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;
}
示例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);
}
示例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());
}
示例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());
}
示例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);
}
示例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);
}
示例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;
}
示例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();
}
示例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);
}
示例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);
}
示例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();
}
}
示例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);*/
}