YARN-4184. Remove update reservation state api from state store as its not used by ReservationSystem (Sean Po via asuresh)
This commit is contained in:
parent
dfbde3fc51
commit
6a61928fb7
|
@ -250,6 +250,9 @@ Release 2.8.0 - UNRELEASED
|
||||||
YARN-1509. Make AMRMClient support send increase container request and
|
YARN-1509. Make AMRMClient support send increase container request and
|
||||||
get increased/decreased containers. (Meng Ding via wangda)
|
get increased/decreased containers. (Meng Ding via wangda)
|
||||||
|
|
||||||
|
YARN-4184. Remove update reservation state api from state store as its not used by
|
||||||
|
ReservationSystem (Sean Po via asuresh)
|
||||||
|
|
||||||
IMPROVEMENTS
|
IMPROVEMENTS
|
||||||
|
|
||||||
YARN-644. Basic null check is not performed on passed in arguments before
|
YARN-644. Basic null check is not performed on passed in arguments before
|
||||||
|
|
|
@ -865,18 +865,6 @@ public class FileSystemRMStateStore extends RMStateStore {
|
||||||
writeFileWithRetries(reservationPath, reservationData, true);
|
writeFileWithRetries(reservationPath, reservationData, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void updateReservationState(
|
|
||||||
ReservationAllocationStateProto reservationAllocation, String planName,
|
|
||||||
String reservationIdName) throws Exception {
|
|
||||||
Path planCreatePath = getNodePath(reservationRoot, planName);
|
|
||||||
Path reservationPath = getNodePath(planCreatePath, reservationIdName);
|
|
||||||
LOG.info("Updating state for reservation " + reservationIdName + " from " +
|
|
||||||
"plan " + planName + " at path " + reservationPath);
|
|
||||||
byte[] reservationData = reservationAllocation.toByteArray();
|
|
||||||
updateFile(reservationPath, reservationData, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void removeReservationState(
|
protected void removeReservationState(
|
||||||
String planName, String reservationIdName) throws Exception {
|
String planName, String reservationIdName) throws Exception {
|
||||||
|
|
|
@ -623,14 +623,6 @@ public class LeveldbRMStateStore extends RMStateStore {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void updateReservationState(
|
|
||||||
ReservationAllocationStateProto reservationAllocation, String planName,
|
|
||||||
String reservationIdName) throws Exception {
|
|
||||||
storeReservationState(reservationAllocation, planName,
|
|
||||||
reservationIdName);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void removeReservationState(String planName,
|
protected void removeReservationState(String planName,
|
||||||
String reservationIdName) throws Exception {
|
String reservationIdName) throws Exception {
|
||||||
|
|
|
@ -243,23 +243,6 @@ public class MemoryRMStateStore extends RMStateStore {
|
||||||
planState.put(reservationId, reservationAllocation);
|
planState.put(reservationId, reservationAllocation);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
protected synchronized void updateReservationState(
|
|
||||||
ReservationAllocationStateProto reservationAllocation, String planName,
|
|
||||||
String reservationIdName) throws Exception {
|
|
||||||
LOG.info("Updating reservationallocation for " + reservationIdName + " " +
|
|
||||||
"for plan " + planName);
|
|
||||||
Map<ReservationId, ReservationAllocationStateProto> planState =
|
|
||||||
state.getReservationState().get(planName);
|
|
||||||
if (planState == null) {
|
|
||||||
throw new YarnRuntimeException("State for plan " + planName + " does " +
|
|
||||||
"not exist");
|
|
||||||
}
|
|
||||||
ReservationId reservationId =
|
|
||||||
ReservationId.parseReservationId(reservationIdName);
|
|
||||||
planState.put(reservationId, reservationAllocation);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected synchronized void removeReservationState(
|
protected synchronized void removeReservationState(
|
||||||
String planName, String reservationIdName) throws Exception {
|
String planName, String reservationIdName) throws Exception {
|
||||||
|
|
|
@ -115,13 +115,6 @@ public class NullRMStateStore extends RMStateStore {
|
||||||
// Do nothing
|
// Do nothing
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void updateReservationState(
|
|
||||||
ReservationAllocationStateProto reservationAllocation, String planName,
|
|
||||||
String reservationIdName) throws Exception {
|
|
||||||
// Do nothing
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void removeRMDTMasterKeyState(DelegationKey delegationKey) throws Exception {
|
public void removeRMDTMasterKeyState(DelegationKey delegationKey) throws Exception {
|
||||||
// Do nothing
|
// Do nothing
|
||||||
|
@ -175,7 +168,4 @@ public class NullRMStateStore extends RMStateStore {
|
||||||
public void removeApplication(ApplicationId removeAppId) throws Exception {
|
public void removeApplication(ApplicationId removeAppId) throws Exception {
|
||||||
// Do nothing
|
// Do nothing
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -162,10 +162,6 @@ public abstract class RMStateStore extends AbstractService {
|
||||||
EnumSet.of(RMStateStoreState.ACTIVE, RMStateStoreState.FENCED),
|
EnumSet.of(RMStateStoreState.ACTIVE, RMStateStoreState.FENCED),
|
||||||
RMStateStoreEventType.STORE_RESERVATION,
|
RMStateStoreEventType.STORE_RESERVATION,
|
||||||
new StoreReservationAllocationTransition())
|
new StoreReservationAllocationTransition())
|
||||||
.addTransition(RMStateStoreState.ACTIVE,
|
|
||||||
EnumSet.of(RMStateStoreState.ACTIVE, RMStateStoreState.FENCED),
|
|
||||||
RMStateStoreEventType.UPDATE_RESERVATION,
|
|
||||||
new UpdateReservationAllocationTransition())
|
|
||||||
.addTransition(RMStateStoreState.ACTIVE,
|
.addTransition(RMStateStoreState.ACTIVE,
|
||||||
EnumSet.of(RMStateStoreState.ACTIVE, RMStateStoreState.FENCED),
|
EnumSet.of(RMStateStoreState.ACTIVE, RMStateStoreState.FENCED),
|
||||||
RMStateStoreEventType.REMOVE_RESERVATION,
|
RMStateStoreEventType.REMOVE_RESERVATION,
|
||||||
|
@ -187,7 +183,6 @@ public abstract class RMStateStore extends AbstractService {
|
||||||
RMStateStoreEventType.UPDATE_DELEGATION_TOKEN,
|
RMStateStoreEventType.UPDATE_DELEGATION_TOKEN,
|
||||||
RMStateStoreEventType.UPDATE_AMRM_TOKEN,
|
RMStateStoreEventType.UPDATE_AMRM_TOKEN,
|
||||||
RMStateStoreEventType.STORE_RESERVATION,
|
RMStateStoreEventType.STORE_RESERVATION,
|
||||||
RMStateStoreEventType.UPDATE_RESERVATION,
|
|
||||||
RMStateStoreEventType.REMOVE_RESERVATION));
|
RMStateStoreEventType.REMOVE_RESERVATION));
|
||||||
|
|
||||||
private final StateMachine<RMStateStoreState,
|
private final StateMachine<RMStateStoreState,
|
||||||
|
@ -524,35 +519,6 @@ public abstract class RMStateStore extends AbstractService {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class UpdateReservationAllocationTransition implements
|
|
||||||
MultipleArcTransition<RMStateStore, RMStateStoreEvent,
|
|
||||||
RMStateStoreState> {
|
|
||||||
@Override
|
|
||||||
public RMStateStoreState transition(RMStateStore store,
|
|
||||||
RMStateStoreEvent event) {
|
|
||||||
if (!(event instanceof RMStateStoreStoreReservationEvent)) {
|
|
||||||
// should never happen
|
|
||||||
LOG.error("Illegal event type: " + event.getClass());
|
|
||||||
return RMStateStoreState.ACTIVE;
|
|
||||||
}
|
|
||||||
boolean isFenced = false;
|
|
||||||
RMStateStoreStoreReservationEvent reservationEvent =
|
|
||||||
(RMStateStoreStoreReservationEvent) event;
|
|
||||||
try {
|
|
||||||
LOG.info("Updating reservation allocation." + reservationEvent
|
|
||||||
.getReservationIdName());
|
|
||||||
store.updateReservationState(
|
|
||||||
reservationEvent.getReservationAllocation(),
|
|
||||||
reservationEvent.getPlanName(),
|
|
||||||
reservationEvent.getReservationIdName());
|
|
||||||
} catch (Exception e) {
|
|
||||||
LOG.error("Error while updating reservation allocation.", e);
|
|
||||||
isFenced = store.notifyStoreOperationFailedInternal(e);
|
|
||||||
}
|
|
||||||
return finalState(isFenced);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private static class RemoveReservationAllocationTransition implements
|
private static class RemoveReservationAllocationTransition implements
|
||||||
MultipleArcTransition<RMStateStore, RMStateStoreEvent,
|
MultipleArcTransition<RMStateStore, RMStateStoreEvent,
|
||||||
RMStateStoreState> {
|
RMStateStoreState> {
|
||||||
|
@ -939,14 +905,6 @@ public abstract class RMStateStore extends AbstractService {
|
||||||
planName, reservationIdName));
|
planName, reservationIdName));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void updateReservation(
|
|
||||||
ReservationAllocationStateProto reservationAllocation,
|
|
||||||
String planName, String reservationIdName) {
|
|
||||||
handleStoreEvent(new RMStateStoreStoreReservationEvent(
|
|
||||||
reservationAllocation, RMStateStoreEventType.UPDATE_RESERVATION,
|
|
||||||
planName, reservationIdName));
|
|
||||||
}
|
|
||||||
|
|
||||||
public void removeReservation(String planName, String reservationIdName) {
|
public void removeReservation(String planName, String reservationIdName) {
|
||||||
handleStoreEvent(new RMStateStoreStoreReservationEvent(
|
handleStoreEvent(new RMStateStoreStoreReservationEvent(
|
||||||
null, RMStateStoreEventType.REMOVE_RESERVATION,
|
null, RMStateStoreEventType.REMOVE_RESERVATION,
|
||||||
|
@ -970,15 +928,6 @@ public abstract class RMStateStore extends AbstractService {
|
||||||
protected abstract void removeReservationState(String planName,
|
protected abstract void removeReservationState(String planName,
|
||||||
String reservationIdName) throws Exception;
|
String reservationIdName) throws Exception;
|
||||||
|
|
||||||
/**
|
|
||||||
* Blocking API
|
|
||||||
* Derived classes must implement this method to update the state of
|
|
||||||
* a reservation allocation.
|
|
||||||
*/
|
|
||||||
protected abstract void updateReservationState(
|
|
||||||
ReservationAllocationStateProto reservationAllocation, String planName,
|
|
||||||
String reservationIdName) throws Exception;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Blocking API
|
* Blocking API
|
||||||
* Derived classes must implement this method to remove the state of
|
* Derived classes must implement this method to remove the state of
|
||||||
|
|
|
@ -34,6 +34,5 @@ public enum RMStateStoreEventType {
|
||||||
UPDATE_DELEGATION_TOKEN,
|
UPDATE_DELEGATION_TOKEN,
|
||||||
UPDATE_AMRM_TOKEN,
|
UPDATE_AMRM_TOKEN,
|
||||||
STORE_RESERVATION,
|
STORE_RESERVATION,
|
||||||
UPDATE_RESERVATION,
|
|
||||||
REMOVE_RESERVATION,
|
REMOVE_RESERVATION,
|
||||||
}
|
}
|
||||||
|
|
|
@ -845,17 +845,6 @@ public class ZKRMStateStore extends RMStateStore {
|
||||||
trx.commit();
|
trx.commit();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
protected synchronized void updateReservationState(
|
|
||||||
ReservationAllocationStateProto reservationAllocation, String planName,
|
|
||||||
String reservationIdName)
|
|
||||||
throws Exception {
|
|
||||||
SafeTransaction trx = new SafeTransaction();
|
|
||||||
addOrUpdateReservationState(
|
|
||||||
reservationAllocation, planName, reservationIdName, trx, true);
|
|
||||||
trx.commit();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void addOrUpdateReservationState(
|
private void addOrUpdateReservationState(
|
||||||
ReservationAllocationStateProto reservationAllocation, String planName,
|
ReservationAllocationStateProto reservationAllocation, String planName,
|
||||||
String reservationIdName, SafeTransaction trx, boolean isUpdate)
|
String reservationIdName, SafeTransaction trx, boolean isUpdate)
|
||||||
|
|
|
@ -760,9 +760,8 @@ public class RMStateStoreTestBase {
|
||||||
minAlloc, hasGang);
|
minAlloc, hasGang);
|
||||||
allocationStateProto =
|
allocationStateProto =
|
||||||
ReservationSystemUtil.buildStateProto(allocation);
|
ReservationSystemUtil.buildStateProto(allocation);
|
||||||
rmContext.getStateStore().updateReservation(
|
rmContext.getStateStore().removeReservation(planName, reservationIdName);
|
||||||
allocationStateProto,
|
rmContext.getStateStore().storeNewReservation(allocationStateProto, planName, reservationIdName);
|
||||||
planName, reservationIdName);
|
|
||||||
|
|
||||||
// load state and verify updated reservation
|
// load state and verify updated reservation
|
||||||
validateStoredReservation(
|
validateStoredReservation(
|
||||||
|
|
Loading…
Reference in New Issue