use of org.apache.karaf.instance.core.Instance in project karaf by apache.
the class DestroyCommand method doExecute.
@SuppressWarnings("deprecation")
protected Object doExecute() throws Exception {
final MultiException exception = new MultiException("Error destroying instance(s)");
for (Instance instance : getMatchingInstances(instances)) {
try {
instance.destroy();
} catch (Exception e) {
exception.addException(e);
}
}
exception.throwIfExceptions();
return null;
}
use of org.apache.karaf.instance.core.Instance in project karaf by apache.
the class ListCommand method doExecute.
protected Object doExecute() throws Exception {
Instance[] instances = getInstanceService().getInstances();
ShellTable table = new ShellTable();
table.column("SSH Port").alignRight();
table.column("SSH Host").alignRight();
table.column("RMI Registry").alignRight();
table.column("RMI Registry Host").alignRight();
table.column("RMI Server").alignRight();
table.column("RMI Server Host").alignRight();
table.column("State");
table.column("PID");
table.column(getRightColumnHeader());
for (Instance instance : instances) {
table.addRow().addContent(instance.getSshPort(), instance.getSshHost(), instance.getRmiRegistryPort(), instance.getRmiRegistryHost(), instance.getRmiServerPort(), instance.getRmiServerHost(), instance.getState(), instance.getPid(), getRightColumnValue(instance));
}
table.print(System.out, !noFormat);
return null;
}
use of org.apache.karaf.instance.core.Instance in project karaf by apache.
the class RestartCommand method doExecute.
@SuppressWarnings("deprecation")
protected Object doExecute() throws Exception {
MultiException exception = new MultiException("Error starting instance(s)");
List<Instance> toWaitFor = new ArrayList<>();
for (Instance instance : getMatchingInstances(instances)) {
try {
String opts = javaOpts;
if (opts == null) {
opts = instance.getJavaOpts();
}
if (opts == null) {
opts = DEFAULT_OPTS;
}
if (debug) {
opts += DEBUG_OPTS;
}
instance.restart(opts);
} catch (Exception e) {
exception.addException(e);
}
}
exception.throwIfExceptions();
while (true) {
boolean allStarted = true;
for (Instance child : toWaitFor) {
allStarted &= Instance.STARTED.equals(child.getState());
}
if (allStarted) {
break;
} else {
Thread.sleep(500);
}
}
return null;
}
use of org.apache.karaf.instance.core.Instance in project karaf by apache.
the class StartCommand method doExecute.
@SuppressWarnings("deprecation")
protected Object doExecute() throws Exception {
MultiException exception = new MultiException("Error starting instance(s)");
List<Instance> toWaitFor = new ArrayList<>();
for (Instance instance : getMatchingInstances(instances)) {
try {
String opts = javaOpts;
if (opts == null) {
opts = instance.getJavaOpts();
}
if (opts == null) {
opts = DEFAULT_OPTS;
}
if (debug) {
opts += DEBUG_OPTS;
}
if (wait) {
String state = instance.getState();
if (Instance.STOPPED.equals(state)) {
instance.start(opts);
toWaitFor.add(instance);
}
} else {
instance.start(opts);
}
} catch (Exception e) {
exception.addException(e);
}
}
exception.throwIfExceptions();
while (true) {
boolean allStarted = true;
for (Instance child : toWaitFor) {
allStarted &= Instance.STARTED.equals(child.getState());
}
if (allStarted) {
break;
} else {
Thread.sleep(500);
}
}
return null;
}
use of org.apache.karaf.instance.core.Instance in project karaf by apache.
the class InstanceServiceMBeanImplTest method testChangeOptions.
public void testChangeOptions() throws Exception {
Instance inst = EasyMock.createMock(Instance.class);
inst.changeJavaOpts("new opts");
EasyMock.expectLastCall();
EasyMock.replay(inst);
InstanceService instanceService = EasyMock.createMock(InstanceService.class);
EasyMock.expect(instanceService.getInstance("test instance")).andReturn(inst);
EasyMock.replay(instanceService);
InstancesMBean instanceServiceMBean = new InstancesMBeanImpl(instanceService);
instanceServiceMBean.changeJavaOpts("test instance", "new opts");
EasyMock.verify(instanceService);
EasyMock.verify(inst);
}
Aggregations