本文整理匯總了Java中io.fabric8.api.Container.getIdentity方法的典型用法代碼示例。如果您正苦於以下問題:Java Container.getIdentity方法的具體用法?Java Container.getIdentity怎麽用?Java Container.getIdentity使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類io.fabric8.api.Container
的用法示例。
在下文中一共展示了Container.getIdentity方法的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: destroyContainerInternal
import io.fabric8.api.Container; //導入方法依賴的package包/類
private Container destroyContainerInternal(Container container) {
ContainerIdentity identity = container.getIdentity();
Set<ContainerIdentity> childIdentities = container.getChildIdentities();
IllegalStateAssertion.assertTrue(childIdentities.isEmpty(), "Cannot destroy a container that has active child containers: " + container);
// Stop the container
if (container.getState() == State.STARTED) {
container = stopContainer(identity);
}
LOGGER.info("Destroy container: {}", container);
ContainerRegistry registry = containerRegistry.get();
ContainerIdentity parentId = container.getParentIdentity();
if (parentId != null) {
LockHandle parentLock = aquireWriteLock(parentId);
try {
registry.removeChildFromParent(parentId, identity);
} finally {
parentLock.unlock();
}
}
return registry.destroyContainer(container.getIdentity());
}
示例2: storeInternal
import io.fabric8.api.Container; //導入方法依賴的package包/類
private void storeInternal(Container container) {
LOGGER.debug("Storing container {}.", container.getIdentity());
ContainerIdentity identity = container.getIdentity();
String id = identity.getSymbolicName();
Container existing = getContainer(identity);
try {
if (existing == null) {
curator.get().create().creatingParentsIfNeeded().forPath(ZkPath.CONTAINER.getPath(id));
}
setParentInternal(identity, container.getParentIdentity());
setChildIdentitiesInternal(identity, container.getChildIdentities());
setRuntimeTypeInternal(identity, container.getRuntimeType());
setProfilesInternal(identity, container.getProfileIdentities());
setVersionInternal(identity, container.getProfileVersion());
setAttributesInternal(ZkPath.CONTAINER_ATTRIBUTES.getPath(id), container.getAttributes());
setStateInternal(identity, container.getState());
setServiceEndpointsInternal(identity, container.getServiceEndpoints());
} catch (Exception e) {
throw FabricException.launderThrowable(e);
}
}
示例3: testManagedKaraf
import io.fabric8.api.Container; //導入方法依賴的package包/類
@Test
@Ignore
public void testManagedKaraf() throws Exception {
// Build the {@link CreateOptions}
Runtime runtime = RuntimeLocator.getRequiredRuntime();
File dataDir = new File((String) runtime.getProperty(RuntimeService.RUNTIME_DATA_DIR));
CreateOptions options = KarafContainerBuilder.create()
.identity("ManagedKaraf")
.outputToConsole(true)
.targetPath(dataDir.toPath())
.getCreateOptions();
ContainerManager cntManager = ContainerManagerLocator.getContainerManager();
Container cnt = cntManager.createContainer(options);
ContainerIdentity cntId = cnt.getIdentity();
try {
// Start the container
cnt = cntManager.startContainer(cntId, null);
verifyContainer(cnt);
} finally {
cnt = cntManager.stopContainer(cntId);
Assert.assertEquals(State.STOPPED, cnt.getState());
}
}
示例4: createAndStart
import io.fabric8.api.Container; //導入方法依賴的package包/類
private ContainerIdentity createAndStart(ContainerManager cntManager, int index) throws InterruptedException, ProvisionException {
CreateOptions options = EmbeddedContainerBuilder.create(prefix + "#" + index).getCreateOptions();
Container cnt = cntManager.createContainer(options);
ContainerIdentity cntId = cnt.getIdentity();
//System.out.println(cnt);
Assert.assertSame(State.CREATED, cnt.getState());
Thread.sleep(10);
cnt = cntManager.startContainer(cntId, null);
//System.out.println(cnt);
Assert.assertSame(State.STARTED, cnt.getState());
return cntId;
}
示例5: testContainerLifecycle
import io.fabric8.api.Container; //導入方法依賴的package包/類
@Test
public void testContainerLifecycle() throws Exception {
CreateOptions options = EmbeddedContainerBuilder.create("cntA").getCreateOptions();
ContainerManager cntManager = ContainerManagerLocator.getContainerManager();
Container cntA = cntManager.createContainer(options);
ContainerIdentity cntIdA = cntA.getIdentity();
Assert.assertEquals("cntA", cntIdA.getCanonicalForm());
Assert.assertSame(State.CREATED, cntA.getState());
Assert.assertEquals(ProfileVersion.DEFAULT_PROFILE_VERSION, cntA.getProfileVersion());
cntA = cntManager.startContainer(cntIdA, null);
Assert.assertSame(State.STARTED, cntA.getState());
Assert.assertEquals(DEFAULT_PROFILE_VERSION, cntA.getProfileVersion());
cntA = cntManager.stopContainer(cntIdA);
Assert.assertSame(State.STOPPED, cntA.getState());
cntA = cntManager.destroyContainer(cntIdA);
Assert.assertSame(State.DESTROYED, cntA.getState());
try {
cntManager.startContainer(cntIdA, null);
Assert.fail("IllegalStateException expected");
} catch (IllegalStateException e) {
// expected
}
}
示例6: testComposisteData
import io.fabric8.api.Container; //導入方法依賴的package包/類
@Test
public void testComposisteData() throws Exception {
CreateOptions options = EmbeddedContainerBuilder.create("cntA")
.addAttribute(AKEY, "AVal")
.addAttribute(BKEY, "BVal")
.getCreateOptions();
ContainerManager cntManager = ContainerManagerLocator.getContainerManager();
Container cntA = cntManager.createContainer(options);
ContainerIdentity idA = cntA.getIdentity();
MBeanServer mbeanServer = ManagementFactory.getPlatformMBeanServer();
ContainerManagement cntManagement = ManagementUtils.getMBeanProxy(mbeanServer, ContainerManagement.OBJECT_NAME, ContainerManagement.class);
CompositeData cdata = cntManagement.getContainer(idA.getCanonicalForm());
Container cntB = ContainerOpenType.getContainer(cdata);
Assert.assertEquals(idA, cntB.getIdentity());
Assert.assertEquals(cntA.getAttributes(), cntB.getAttributes());
cntManager.destroyContainer(idA);
// Test the {@link CompositeDataOptionsProvider}
EmbeddedContainerBuilder cntBuilder = EmbeddedContainerBuilder.create();
cntBuilder.addOptions(new CompositeDataOptionsProvider(cdata));
options = cntBuilder.getCreateOptions();
Container cntC = cntManager.createContainer(options);
ContainerIdentity idC = cntC.getIdentity();
Assert.assertEquals("cntA", idC.getCanonicalForm());
Assert.assertEquals(cntA.getAttributes(), cntC.getAttributes());
cntManager.destroyContainer(idC);
}
示例7: testManagedTomcat
import io.fabric8.api.Container; //導入方法依賴的package包/類
@Test
@Ignore
public void testManagedTomcat() throws Exception {
// Build the {@link CreateOptions}
Runtime runtime = RuntimeLocator.getRequiredRuntime();
File dataDir = new File((String) runtime.getProperty(RuntimeService.RUNTIME_DATA_DIR));
CreateOptions options = TomcatContainerBuilder.create()
.identity("ManagedTomcat")
.outputToConsole(true)
//.jvmArguments("-agentlib:jdwp=transport=dt_socket,address=8000,server=y,suspend=n")
.targetPath(dataDir.toPath())
.getCreateOptions();
ContainerManager cntManager = ContainerManagerLocator.getContainerManager();
Container cnt = cntManager.createContainer(options);
ContainerIdentity cntId = cnt.getIdentity();
try {
// Start the container
cnt = cntManager.startContainer(cntId, null);
verifyContainer(cnt);
} finally {
cnt = cntManager.stopContainer(cntId);
Assert.assertEquals(State.STOPPED, cnt.getState());
}
}
示例8: testManagedWildFly
import io.fabric8.api.Container; //導入方法依賴的package包/類
@Test
@Ignore
public void testManagedWildFly() throws Exception {
// Build the {@link CreateOptions}
Runtime runtime = RuntimeLocator.getRequiredRuntime();
File dataDir = new File((String) runtime.getProperty(RuntimeService.RUNTIME_DATA_DIR));
// [TODO] #49 Default port of the running WildFly server is available, why?
CreateOptions options = WildFlyContainerBuilder.create()
.identity("ManagedWildFly")
.outputToConsole(true)
.targetPath(dataDir.toPath())
.managementNativePort(WildFlyCreateOptions.DEFAULT_MANAGEMENT_NATIVE_PORT + 1)
.managementHttpPort(WildFlyCreateOptions.DEFAULT_MANAGEMENT_HTTP_PORT + 1)
.getCreateOptions();
ContainerManager cntManager = ContainerManagerLocator.getContainerManager();
Container cnt = cntManager.createContainer(options);
ContainerIdentity cntId = cnt.getIdentity();
try {
// Start the container
cnt = cntManager.startContainer(cntId, null);
verifyContainer(cnt);
} finally {
cnt = cntManager.stopContainer(cntId);
Assert.assertEquals(State.STOPPED, cnt.getState());
}
}