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:
Arun Suresh 2015-11-17 15:50:34 -08:00
parent dfbde3fc51
commit 6a61928fb7
9 changed files with 5 additions and 113 deletions

View File

@ -250,6 +250,9 @@ Release 2.8.0 - UNRELEASED
YARN-1509. Make AMRMClient support send increase container request and
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
YARN-644. Basic null check is not performed on passed in arguments before

View File

@ -865,18 +865,6 @@ protected void storeReservationState(
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
protected void removeReservationState(
String planName, String reservationIdName) throws Exception {

View File

@ -623,14 +623,6 @@ protected void storeReservationState(
}
}
@Override
protected void updateReservationState(
ReservationAllocationStateProto reservationAllocation, String planName,
String reservationIdName) throws Exception {
storeReservationState(reservationAllocation, planName,
reservationIdName);
}
@Override
protected void removeReservationState(String planName,
String reservationIdName) throws Exception {

View File

@ -243,23 +243,6 @@ protected synchronized void storeReservationState(
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
protected synchronized void removeReservationState(
String planName, String reservationIdName) throws Exception {

View File

@ -115,13 +115,6 @@ protected void removeReservationState(String planName,
// Do nothing
}
@Override
protected void updateReservationState(
ReservationAllocationStateProto reservationAllocation, String planName,
String reservationIdName) throws Exception {
// Do nothing
}
@Override
public void removeRMDTMasterKeyState(DelegationKey delegationKey) throws Exception {
// Do nothing
@ -175,7 +168,4 @@ public void deleteStore() throws Exception {
public void removeApplication(ApplicationId removeAppId) throws Exception {
// Do nothing
}
}

View File

@ -162,10 +162,6 @@ RMStateStoreEventType.REMOVE_APP, new RemoveAppTransition())
EnumSet.of(RMStateStoreState.ACTIVE, RMStateStoreState.FENCED),
RMStateStoreEventType.STORE_RESERVATION,
new StoreReservationAllocationTransition())
.addTransition(RMStateStoreState.ACTIVE,
EnumSet.of(RMStateStoreState.ACTIVE, RMStateStoreState.FENCED),
RMStateStoreEventType.UPDATE_RESERVATION,
new UpdateReservationAllocationTransition())
.addTransition(RMStateStoreState.ACTIVE,
EnumSet.of(RMStateStoreState.ACTIVE, RMStateStoreState.FENCED),
RMStateStoreEventType.REMOVE_RESERVATION,
@ -187,7 +183,6 @@ RMStateStoreEventType.REMOVE_APP, new RemoveAppTransition())
RMStateStoreEventType.UPDATE_DELEGATION_TOKEN,
RMStateStoreEventType.UPDATE_AMRM_TOKEN,
RMStateStoreEventType.STORE_RESERVATION,
RMStateStoreEventType.UPDATE_RESERVATION,
RMStateStoreEventType.REMOVE_RESERVATION));
private final StateMachine<RMStateStoreState,
@ -524,35 +519,6 @@ public RMStateStoreState transition(RMStateStore store,
}
}
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
MultipleArcTransition<RMStateStore, RMStateStoreEvent,
RMStateStoreState> {
@ -939,14 +905,6 @@ public void storeNewReservation(
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) {
handleStoreEvent(new RMStateStoreStoreReservationEvent(
null, RMStateStoreEventType.REMOVE_RESERVATION,
@ -970,15 +928,6 @@ protected abstract void storeReservationState(
protected abstract void removeReservationState(String planName,
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
* Derived classes must implement this method to remove the state of

View File

@ -34,6 +34,5 @@ public enum RMStateStoreEventType {
UPDATE_DELEGATION_TOKEN,
UPDATE_AMRM_TOKEN,
STORE_RESERVATION,
UPDATE_RESERVATION,
REMOVE_RESERVATION,
}

View File

@ -845,17 +845,6 @@ protected synchronized void storeReservationState(
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(
ReservationAllocationStateProto reservationAllocation, String planName,
String reservationIdName, SafeTransaction trx, boolean isUpdate)

View File

@ -760,9 +760,8 @@ public void testReservationStateStore(
minAlloc, hasGang);
allocationStateProto =
ReservationSystemUtil.buildStateProto(allocation);
rmContext.getStateStore().updateReservation(
allocationStateProto,
planName, reservationIdName);
rmContext.getStateStore().removeReservation(planName, reservationIdName);
rmContext.getStateStore().storeNewReservation(allocationStateProto, planName, reservationIdName);
// load state and verify updated reservation
validateStoredReservation(