@Override public boolean apply(SlotStatus slotStatus) { return slotStatus.getState() == state; } }
public SlotStatus terminateSlot(UUID slotId) { Preconditions.checkNotNull(slotId, "slotId must not be null"); Slot slot = slots.get(slotId); if (slot == null) { return null; } SlotStatus status = slot.terminate(); if (status.getState() == TERMINATED) { slots.remove(slotId); } return status; }
public AgentStatus changeSlotStatus(SlotStatus slotStatus) { Map<UUID,SlotStatus> slots = newHashMap(this.slots); if (slotStatus.getState() != TERMINATED) { slots.put(slotStatus.getId(), slotStatus); } else { slots.remove(slotStatus.getId()); } return new AgentStatus(agentId, state, instanceId, internalUri, externalUri, location, instanceType, slots.values(), resources); }
public List<SlotStatus> terminate(Predicate<SlotStatus> filter, String expectedSlotsVersion) { Preconditions.checkNotNull(filter, "filter is null"); // filter the slots List<RemoteSlot> filteredSlots = selectRemoteSlots(filter, expectedSlotsVersion); ImmutableList.Builder<SlotStatus> builder = ImmutableList.builder(); for (RemoteSlot slot : filteredSlots) { if (filter.apply(slot.status())) { SlotStatus slotStatus = slot.terminate(); if (slotStatus.getState() == TERMINATED) { stateManager.deleteExpectedState(slotStatus.getId()); } builder.add(slotStatus); } } return builder.build(); }
@Override public SlotStatus apply(SlotStatus slotStatus) { if (slotStatus.getState() != SlotLifecycleState.UNKNOWN) { stateManager.setExpectedState(new ExpectedSlotStatus(slotStatus.getId(), slotStatus.getState(), slotStatus.getAssignment())); } else { stateManager.deleteExpectedState(slotStatus.getId()); } return slotStatus; } }));
@Override public SlotStatus terminate() { lock(); try { if (!terminated) { SlotStatus status = status(); if (status.getState() != STOPPED) { return status; } // terminate the slot deploymentManager.terminate(); terminated = true; } SlotStatus slotStatus = lastSlotStatus.get().changeState(TERMINATED); lastSlotStatus.set(slotStatus); return slotStatus; } finally { unlock(); } }
for (RemoteSlot slot : filteredSlots) { SlotStatus status = slot.status(); SlotLifecycleState state = status.getState(); if (state != TERMINATED && state != UNKNOWN) { Assignment assignment = upgradeVersions.upgradeAssignment(repository, status.getAssignment());
@Override public ImmutableList<ServiceDescriptor> getServiceInventory(Iterable<SlotStatus> allSlotStatus) { ImmutableList.Builder<ServiceDescriptor> newDescriptors = ImmutableList.builder(); for (SlotStatus slotStatus : allSlotStatus) { // if the self reference is null, the slot is totally offline so skip for now if (slotStatus.getSelf() == null) { continue; } List<ServiceDescriptor> serviceDescriptors = getServiceInventory(slotStatus); if (serviceDescriptors == null) { continue; } for (ServiceDescriptor serviceDescriptor : serviceDescriptors) { newDescriptors.add(new ServiceDescriptor(null, slotStatus.getId().toString(), serviceDescriptor.getType(), serviceDescriptor.getPool(), slotStatus.getLocation(), slotStatus.getState() == SlotLifecycleState.RUNNING ? ServiceState.RUNNING : ServiceState.STOPPED, interpolateProperties(serviceDescriptor.getProperties(), slotStatus))); } } return newDescriptors.build(); }
if (!Objects.equal(actualState.getState(), expectedState.getStatus())) { messages.add("Expected state to be " + expectedState.getStatus());
stateManager.setExpectedState(new ExpectedSlotStatus(slotStatus.getId(), slotStatus.getState(), slotStatus.getAssignment()));
config, shortConfig, status.getState().toString(), status.getVersion(), status.getStatusMessage(),
config, shortConfig, slotStatus.getState().toString(), slotStatus.getVersion(), slotStatus.getStatusMessage(),