-
Notifications
You must be signed in to change notification settings - Fork 3
Open
Description
public void handleCmd(Byte command, byte[] bytes, String replyTo) throws Exception {
......
} else if(this.customContainers.containsKey(e)) {
Component e1 = (Component)this.customContainers.get(e);
int runningCustomContainersCount = this.customContainersRunning.containsKey(e)?((Integer)this.customContainersRunning.get(e)).intValue():0;
if(AbstractDockerizer.class.isInstance(e1)) {
ArrayList envVars = new ArrayList(Arrays.asList(buffer.environmentVariables));
commandToSend = ((AbstractDockerizer)e1).clone(envVars);
containerName = ((AbstractDockerizer)commandToSend).createContainerWithRemoveAllPrevs((String[])envVars.toArray(new String[0]));
} else {
commandToSend = (Component)e1.getClass().getConstructor(new Class[0]).newInstance(new Object[0]);
containerName = e + "_" + runningCustomContainersCount;
}
++runningCustomContainersCount;
this.customContainersRunning.put(e, Integer.valueOf(runningCustomContainersCount));
}
........
}
if(commandToSend != null) {
if(AbstractDockerizer.class.isInstance(commandToSend)) {
commandToSend = ((AbstractDockerizer)commandToSend).clone(new ArrayList(Arrays.asList(buffer.environmentVariables)));
containerName = ((AbstractDockerizer)commandToSend).createContainerWithRemoveAllPrevs(buffer.environmentVariables);
} else {
commandToSend = (Component)commandToSend.getClass().getConstructor(new Class[0]).newInstance(new Object[0]);
}
.....
}
When the component to create is a custom component, the method to create the component is called twice (for both cases: if it is instance of AbstractDockerizer or java component ). First, component is created when this condition is true
else if(this.customContainers.containsKey(e)) { ....
And then again, inside the next condition:
else if(this.customContainers.containsKey(e)) {...
Though the createContainerWithRemoveAllPrevs() removes the containers with the same name first, so the right number of containers are created. But when there are a lot of containers are to be created with image sizes (like in my usecase), then it takes double the time to create those components.
Metadata
Metadata
Assignees
Labels
No labels