Skip to content

Commit

Permalink
Got rid of some duplicated code
Browse files Browse the repository at this point in the history
  • Loading branch information
Alena Prokharchyk committed Jul 27, 2015
1 parent 119989e commit 2e93f83
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 33 deletions.
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
package io.cattle.platform.servicediscovery.deployment;

import static io.cattle.platform.core.model.tables.InstanceHostMapTable.INSTANCE_HOST_MAP;
import io.cattle.platform.core.constants.HealthcheckConstants;
import io.cattle.platform.core.constants.InstanceConstants;
import io.cattle.platform.core.model.Instance;
import io.cattle.platform.core.model.InstanceHostMap;
import io.cattle.platform.core.model.Service;
import io.cattle.platform.object.resource.ResourcePredicate;
import io.cattle.platform.servicediscovery.deployment.impl.DeploymentManagerImpl;

public abstract class AbstractInstanceUnit extends DeploymentUnitInstance implements InstanceUnit {
Expand Down Expand Up @@ -41,4 +44,17 @@ public void stop() {
public boolean isHealthCheckInitializing() {
return instance != null && HealthcheckConstants.HEALTH_STATE_INITIALIZING.equals(instance.getHealthState());
}

@Override
public void waitForAllocate() {
if (this.instance != null) {
instance = context.resourceMonitor.waitFor(instance, new ResourcePredicate<Instance>() {
@Override
public boolean evaluate(Instance obj) {
return context.objectManager.find(InstanceHostMap.class, INSTANCE_HOST_MAP.INSTANCE_ID,
instance.getId()).size() > 0;
}
});
}
}
}
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
package io.cattle.platform.servicediscovery.deployment.impl;

import static io.cattle.platform.core.model.tables.InstanceHostMapTable.*;

import io.cattle.platform.core.constants.CommonStatesConstants;
import io.cattle.platform.core.constants.InstanceConstants;
import io.cattle.platform.core.model.Instance;
import io.cattle.platform.core.model.InstanceHostMap;
import io.cattle.platform.core.model.Service;
import io.cattle.platform.core.model.ServiceExposeMap;
import io.cattle.platform.engine.process.impl.ProcessCancelException;
Expand Down Expand Up @@ -113,18 +110,5 @@ public void waitForNotTransitioning() {
this.instance = context.resourceMonitor.waitForNotTransitioning(this.instance);
}
}

@Override
public void waitForAllocate() {
if (this.instance != null) {
instance = context.resourceMonitor.waitFor(instance, new ResourcePredicate<Instance>() {
@Override
public boolean evaluate(Instance obj) {
return context.objectManager.find(InstanceHostMap.class, INSTANCE_HOST_MAP.INSTANCE_ID,
instance.getId()).size() > 0;
}
});
}
}
}

Original file line number Diff line number Diff line change
@@ -1,13 +1,10 @@
package io.cattle.platform.servicediscovery.deployment.impl;

import static io.cattle.platform.core.model.tables.InstanceHostMapTable.*;
import static io.cattle.platform.core.model.tables.LoadBalancerTable.*;

import static io.cattle.platform.core.model.tables.LoadBalancerTable.LOAD_BALANCER;
import io.cattle.platform.core.constants.CommonStatesConstants;
import io.cattle.platform.core.constants.InstanceConstants;
import io.cattle.platform.core.constants.LoadBalancerConstants;
import io.cattle.platform.core.model.Instance;
import io.cattle.platform.core.model.InstanceHostMap;
import io.cattle.platform.core.model.LoadBalancer;
import io.cattle.platform.core.model.LoadBalancerHostMap;
import io.cattle.platform.core.model.Service;
Expand Down Expand Up @@ -106,17 +103,4 @@ public void waitForNotTransitioning() {
this.hostMap = context.resourceMonitor.waitForNotTransitioning(this.hostMap);
}
}

@Override
public void waitForAllocate() {
if (this.instance != null) {
instance = context.resourceMonitor.waitFor(instance, new ResourcePredicate<Instance>() {
@Override
public boolean evaluate(Instance obj) {
return context.objectManager.find(InstanceHostMap.class, INSTANCE_HOST_MAP.INSTANCE_ID,
instance.getId()).size() > 0;
}
});
}
}
}

0 comments on commit 2e93f83

Please sign in to comment.