@Override protected void serviceStop() throws Exception { if (stateStore != null) { stateStore.stop(); } super.serviceStop(); }
/** * Shutdown the state storage. * * @throws IOException */ @Override public void serviceStop() throws IOException { closeStorage(); }
@Test public void testTokenStore() throws Exception { initAndStartTimelineServiceStateStoreService(); TimelineServiceState state = store.loadState(); assertTrue("token state not empty", state.tokenState.isEmpty()); assertTrue("key state not empty", state.tokenMasterKeyState.isEmpty()); store.storeTokenMasterKey(key1); try { store.storeTokenMasterKey(key1); fail("redundant store of key undetected"); } catch (IOException e) { store.storeToken(token1, tokenDate1); store.storeToken(token2, tokenDate2); try { store.storeToken(token1, tokenDate1); fail("redundant store of token undetected"); } catch (IOException e) { store.close(); state = store.loadState(); assertEquals("incorrect loaded token count", 2, state.tokenState.size()); assertTrue("missing token 1", state.tokenState.containsKey(token1)); store.removeToken(token1); store.storeTokenMasterKey(key2); final Long newTokenDate2 = 975318642L; store.updateToken(token2, newTokenDate2);
@Override protected void removeStoredMasterKey(DelegationKey key) { if (LOG.isDebugEnabled()) { LOG.debug("Removing master key " + key.getKeyId()); } try { if (stateStore != null) { stateStore.removeTokenMasterKey(key); } } catch (IOException e) { LOG.error("Unable to remove master key " + key.getKeyId(), e); } }
@Override protected void serviceInit(Configuration conf) throws Exception { if (conf.getBoolean(YarnConfiguration.TIMELINE_SERVICE_RECOVERY_ENABLED, YarnConfiguration.DEFAULT_TIMELINE_SERVICE_RECOVERY_ENABLED)) { stateStore = createStateStore(conf); stateStore.init(conf); } super.serviceInit(conf); }
@Override protected void storeNewMasterKey(DelegationKey key) throws IOException { if (LOG.isDebugEnabled()) { LOG.debug("Storing master key " + key.getKeyId()); } try { if (stateStore != null) { stateStore.storeTokenMasterKey(key); } } catch (IOException e) { LOG.error("Unable to store master key " + key.getKeyId(), e); } }
@Override protected void updateStoredToken(TimelineDelegationTokenIdentifier tokenId, long renewDate) { if (LOG.isDebugEnabled()) { LOG.debug("Updating token " + tokenId.getSequenceNumber()); } try { if (stateStore != null) { stateStore.updateToken(tokenId, renewDate); } } catch (IOException e) { LOG.error("Unable to update token " + tokenId.getSequenceNumber(), e); } }
@Override protected void removeStoredToken(TimelineDelegationTokenIdentifier tokenId) throws IOException { if (LOG.isDebugEnabled()) { LOG.debug("Storing token " + tokenId.getSequenceNumber()); } try { if (stateStore != null) { stateStore.removeToken(tokenId); } } catch (IOException e) { LOG.error("Unable to remove token " + tokenId.getSequenceNumber(), e); } }
@Override protected void storeNewToken(TimelineDelegationTokenIdentifier tokenId, long renewDate) { if (LOG.isDebugEnabled()) { LOG.debug("Storing token " + tokenId.getSequenceNumber()); } try { if (stateStore != null) { stateStore.storeToken(tokenId, renewDate); } } catch (IOException e) { LOG.error("Unable to store token " + tokenId.getSequenceNumber(), e); } }
@Override protected void removeStoredMasterKey(DelegationKey key) { if (LOG.isDebugEnabled()) { LOG.debug("Removing master key " + key.getKeyId()); } try { if (stateStore != null) { stateStore.removeTokenMasterKey(key); } } catch (IOException e) { LOG.error("Unable to remove master key " + key.getKeyId(), e); } }
@Override protected void serviceInit(Configuration conf) throws Exception { if (conf.getBoolean(YarnConfiguration.TIMELINE_SERVICE_RECOVERY_ENABLED, YarnConfiguration.DEFAULT_TIMELINE_SERVICE_RECOVERY_ENABLED)) { stateStore = createStateStore(conf); stateStore.init(conf); } long secretKeyInterval = conf.getLong(YarnConfiguration.TIMELINE_DELEGATION_KEY_UPDATE_INTERVAL, YarnConfiguration.DEFAULT_TIMELINE_DELEGATION_KEY_UPDATE_INTERVAL); long tokenMaxLifetime = conf.getLong(YarnConfiguration.TIMELINE_DELEGATION_TOKEN_MAX_LIFETIME, YarnConfiguration.DEFAULT_TIMELINE_DELEGATION_TOKEN_MAX_LIFETIME); long tokenRenewInterval = conf.getLong(YarnConfiguration.TIMELINE_DELEGATION_TOKEN_RENEW_INTERVAL, YarnConfiguration.DEFAULT_TIMELINE_DELEGATION_TOKEN_RENEW_INTERVAL); secretManager = new TimelineDelegationTokenSecretManager(secretKeyInterval, tokenMaxLifetime, tokenRenewInterval, 3600000, stateStore); super.init(conf); }
@Override protected void storeNewMasterKey(DelegationKey key) throws IOException { if (LOG.isDebugEnabled()) { LOG.debug("Storing master key " + key.getKeyId()); } try { if (stateStore != null) { stateStore.storeTokenMasterKey(key); } } catch (IOException e) { LOG.error("Unable to store master key " + key.getKeyId(), e); } }
@Override protected void updateStoredToken(TimelineDelegationTokenIdentifier tokenId, long renewDate) { if (LOG.isDebugEnabled()) { LOG.debug("Updating token " + tokenId.getSequenceNumber()); } try { if (stateStore != null) { stateStore.updateToken(tokenId, renewDate); } } catch (IOException e) { LOG.error("Unable to update token " + tokenId.getSequenceNumber(), e); } }
@Override protected void removeStoredToken(TimelineDelegationTokenIdentifier tokenId) throws IOException { if (LOG.isDebugEnabled()) { LOG.debug("Storing token " + tokenId.getSequenceNumber()); } try { if (stateStore != null) { stateStore.removeToken(tokenId); } } catch (IOException e) { LOG.error("Unable to remove token " + tokenId.getSequenceNumber(), e); } }
@Override protected void storeNewToken(TimelineDelegationTokenIdentifier tokenId, long renewDate) { if (LOG.isDebugEnabled()) { LOG.debug("Storing token " + tokenId.getSequenceNumber()); } try { if (stateStore != null) { stateStore.storeToken(tokenId, renewDate); } } catch (IOException e) { LOG.error("Unable to store token " + tokenId.getSequenceNumber(), e); } }
@Override protected void serviceStop() throws Exception { if (stateStore != null) { stateStore.stop(); } secretManager.stopThreads(); super.stop(); }