public String toString() { String s = "StartStopInstance " + c.getName(); if (start) { s += " start"; } else { s += " stop"; } return s; }
public String toString() { return "AddInstance " + c.getName(); } }
public String toString() { return "UpdateDictionary " + c.getName(); }
public String toString() { return "RemoveInstance " + c.getName(); }
public String toString() { return "UpdateCallMethod " + c.getName(); }
public void run() { try { // FIXME when a deployUnit will have multiple DeployUnit, we need to find the right one... Thread.currentThread().setContextClassLoader(iact.getKcl()); ModelRegistry.current.set(registry); if (start) { Thread.currentThread().setName("KevoreeStartInstance" + c.getName()); resultAsync = iact.kInstanceStart(root); } else { Thread.currentThread().setName("KevoreeStopInstance" + c.getName()); boolean res = iact.kInstanceStop(root); if (!res) { Log.error("Error while Stopping Wrapper "); } Thread.currentThread().setContextClassLoader(null); resultAsync = res; } } catch (Exception e) { e.printStackTrace(); } }
private static void apply(Instance leftH, ContainerNode targetNode) { if (leftH instanceof ComponentInstance) { targetNode.addComponents((ComponentInstance) leftH); } else { if (leftH instanceof ContainerNode) { targetNode.addHosts((ContainerNode) leftH); } else { throw new KevScriptError("\""+leftH.getName()+"\" is not a node instance nor a component. Move failed"); } } } }
private static void apply(Instance leftH, ContainerNode targetNode) throws KevScriptException { if (leftH instanceof ComponentInstance) { targetNode.addComponents((ComponentInstance) leftH); } else { if (leftH instanceof ContainerNode) { targetNode.addHosts((ContainerNode) leftH); } else { throw new KevScriptException("\""+leftH.getName()+"\" is not a node instance nor a component. Move failed"); } } } }
tempFile = File.createTempFile("bootModel" + getModelElement().getName(), ".json"); FileOutputStream tempIO = new FileOutputStream(tempFile); modelSaver.serializeToStream(tmodel, tempIO); execArray.add("-Dnode.name=" + getModelElement().getName()); execArray.add("org.kevoree.platform.standalone.App"); readerOUTthread = new Thread(new Reader(process.getInputStream(), getModelElement().getName(), false)); readerERRthread = new Thread(new Reader(process.getErrorStream(), getModelElement().getName(), true)); readerOUTthread.start(); readerERRthread.start();
public boolean execute() { List<KMFContainer> metas = c.getTypeDefinition().select("deployUnits[]/filters[name=platform,value=java]"); if (metas.isEmpty()) { Log.error("No DeployUnit found for '" + c.getName() + ": " + c.getTypeDefinition().getName() + "/" + c.getTypeDefinition().getVersion() + "' that matches the 'java' platform"); return false; } Thread subThread = null; try { tg = new KevoreeThreadGroup("kev/" + c.path()); subThread = new Thread(tg, this); subThread.start(); subThread.join(); return resultSub; } catch (Throwable e) { if (subThread != null) { try { //subThread.stop(); //kill sub thread subThread.interrupt(); } catch (Throwable t) { //ignore killing thread } } Log.error("Could not add the instance {}:{}", c.getName(), c.getTypeDefinition().getName(), e); return false; } }
public void run() { try { FlexyClassLoader newKCL = ClassLoaderHelper.createInstanceClassLoader(c, nodeName, bs); Thread.currentThread().setContextClassLoader(newKCL); Thread.currentThread().setName("KevoreeAddInstance" + c.getName()); KInstanceWrapper newBeanKInstanceWrapper; if (c instanceof ContainerNode) { newBeanKInstanceWrapper = wrapperFactory.wrap(c, this/* nodeInstance is useless because launched as external process */, tg, bs, modelService); newBeanKInstanceWrapper.setKcl(newKCL); registry.register(c, newBeanKInstanceWrapper); } else { Object newBeanInstance = bs.createInstance(c, newKCL); newBeanKInstanceWrapper = wrapperFactory.wrap(c, newBeanInstance, tg, bs, modelService); newBeanKInstanceWrapper.setKcl(newKCL); registry.register(c, newBeanKInstanceWrapper); bs.injectDictionary(c, newBeanInstance, true); } newBeanKInstanceWrapper.create(); resultSub = true; Thread.currentThread().setContextClassLoader(null); Log.info("Add instance {}", c.path()); } catch(Throwable e) { Log.error("Error while adding instance {}", e, c.getName()); resultSub = false; } }
private String instance2fqn(Instance instance) { if (instance instanceof ContainerNode || instance instanceof Group || instance instanceof Channel) { return instance.getName() + ": " + instance.getTypeDefinition().getName() + "/" + instance.getTypeDefinition().getVersion(); } else { return ((NamedElement) instance.eContainer()).getName() + "." + instance.getName() + ": " + instance.getTypeDefinition().getName() + "/" + instance.getTypeDefinition().getVersion(); } } }
@Override public Object createInstance(final Instance instance, final FlexyClassLoader classLoader) { try { final String mainClassName = searchMainClassName(instance); final Class clazz = classLoader.loadClass(mainClassName); final Object newInstance = clazz.newInstance(); injector.register(Context.class, new InstanceContext(instance.path(), nodeName, instance.getName())); injector.register(ModelService.class, new ContextAwareAdapter(core, instance.path())); injector.register(PlatformService.class, core); injector.inject(newInstance); return newInstance; } catch (final Exception e) { Log.error("Error while creating instance \"{}\" of type {}", e, instance.getName(), instance.getTypeDefinition().getName()); } return null; }
@Override public synchronized Object createInstance(final Instance instance, final ClassLoader classLoader) throws KevoreeCoreException { final DeployUnit du = getJavaDeployUnit(instance); try { final String mainClassName = searchMainClassName(instance); final Class clazz = classLoader.loadClass(mainClassName); final Object newInstance = clazz.newInstance(); final InstanceContext instanceContext = new InstanceContext(instance.path(), core.getNodeName(), instance.getName()); injector.register(Context.class, instanceContext); injector.register(ModelService.class, new ContextAwareModelServiceAdapter(core, instance.path())); // TODO there should be a GroupContext also that gives attached nodes etc.. injector.register(ChannelContext.class, new ChannelContextImpl(instanceContext)); injector.inject(newInstance); return newInstance; } catch (NoClassDefFoundError e) { throw new KevoreeCoreException("@KevoreeInject failed (is " + du.getName() + ":" + du.getVersion() + ":"+du.getHashcode().substring(0, 6)+" up-to-date?)", e); } catch (Throwable e) { throw new KevoreeCoreException("Unable to create instance " + instance.getName(), e); } }
@Override public boolean kInstanceStart(ContainerRoot model) { if (!getIsStarted()) { try { Method met = getResolver().resolve(org.kevoree.annotation.Start.class); if (met != null) { met.invoke(getTargetObj()); } setIsStarted(true); processPending(); return true; } catch (InvocationTargetException e) { Log.error("Kevoree Channel Instance Start Error !", e.getCause()); return false; } catch (Exception e) { Log.error("Kevoree Channel Instance Start Error !", e); return false; } } else { Log.error("Try to start the channel {} while it is already start", getModelElement().getName()); return false; } }
private void debug(Value value) { Instance instance = (Instance) value.eContainer().eContainer(); DictionaryAttribute attr = instance.getTypeDefinition().getDictionaryType().findAttributesByID(value.getName()); if (attr.getFragmentDependant()) { Log.debug("Update param for {}.{}/{} = '{}'", instance.getName(), value.getName(), ((NamedElement) value.eContainer()).getName(), value.getValue()); } else { Log.debug("Update param for {}.{} = '{}'", instance.getName(), value.getName(), value.getValue()); } }
if (dicAtt == null) { throw new KevScriptError( "Param does not exist in type " + target.getName() + " -> " + propName); } else { dicValue.setName(dicAtt.getName()); } else { for (final Instance targetNode : targetNodes) { if (target.findFragmentDictionaryByID(targetNode.getName()) == null) { final FragmentDictionary newDictionary = factory.createFragmentDictionary(); newDictionary.setName(targetNode.getName()); target.addFragmentDictionary(newDictionary); Value dicValue = target.findFragmentDictionaryByID(targetNode.getName()) .findValuesByID(propName); if (dicValue == null) { if (dicAtt == null) { throw new KevScriptError( "Param does not existe in type " + target.getName() + " -> " + propName); } else { if (!dicAtt.getFragmentDependant()) { target.findFragmentDictionaryByID(targetNode.getName()).addValues(dicValue);
if (((Instance) p.getRef()).getName().equals(nodeName)) { return new SelfDictionaryUpdate((Instance) p.getRef(), nodeType); } else {
Log.error("Unable to find instance: " + c.getName()); return false;