/** * Removes our metadata of all executors registered for the given application, and optionally also * deletes the local directories associated with the executors of that application in a separate * thread. * * <p>It is not valid to call registerExecutor() for an executor with this appId after invoking * this method. */ public void applicationRemoved(String appId, boolean cleanupLocalDirs) { logger.info("Application {} removed, cleanupLocalDirs = {}", appId, cleanupLocalDirs); Iterator<Map.Entry<AppExecId, ExecutorShuffleInfo>> it = executors.entrySet().iterator(); while (it.hasNext()) { Map.Entry<AppExecId, ExecutorShuffleInfo> entry = it.next(); AppExecId fullId = entry.getKey(); final ExecutorShuffleInfo executor = entry.getValue(); // Only touch executors associated with the appId that was removed. if (appId.equals(fullId.appId)) { it.remove(); if (db != null) { try { db.delete(dbAppExecKey(fullId)); } catch (IOException e) { logger.error("Error deleting {} from executor state db", appId, e); } } if (cleanupLocalDirs) { logger.info("Cleaning up executor {}'s {} local dirs", fullId, executor.localDirs.length); // Execute the actual deletion in a different thread, as it may take some time. directoryCleaner.execute( new Runnable() { @Override public void run() { deleteExecutorDirs(executor.localDirs); } }); } } } }
@Override protected void removeRMDTMasterKeyState(DelegationKey masterKey) throws IOException { String dbKey = getRMDTMasterKeyNodeKey(masterKey); if (LOG.isDebugEnabled()) { LOG.debug("Removing token master key at " + dbKey); } try { db.delete(bytes(dbKey)); } catch (DBException e) { throw new IOException(e); } }
public void save() { boolean isNoticed = false; if (!notice.isVisible()) { isNoticed = true; notice.setVisible(true); notice.setText("Saving..."); } if (getOptions() != null) { DB database = null; try { database = factory.open(this.leveldbStore.getSelectedFile(), getOptions()); DBIterator iterator = database.iterator(); HashSet<byte[]> keys = new HashSet<>(); for (iterator.seekToFirst(); iterator.hasNext(); iterator.next()) { keys.add(iterator.peekNext().getKey()); } iterator.close(); for (byte[] key : keys) { database.delete(key); } for (int i = 0; i < dataList.getModel().getSize(); ++i) { DBItem item = dataList.getModel().getElementAt(i); database.put(item.key, item.value); } } catch (Exception e) { JOptionPane.showMessageDialog(pane, "Unable to open database:\n" + e); e.printStackTrace(); } finally { if (database != null) { try { database.close(); } catch (IOException e) { JOptionPane.showMessageDialog(pane, "Unable to close database:\n" + e); e.printStackTrace(); } } saveButton.setEnabled(false); } } if (isNoticed) { try { Thread.sleep(100); } catch (InterruptedException e) { e.printStackTrace(); } notice.setVisible(false); notice.setText(""); } }
@Override protected void removeRMDelegationTokenState(RMDelegationTokenIdentifier tokenId) throws IOException { String tokenKey = getRMDTTokenNodeKey(tokenId); if (LOG.isDebugEnabled()) { LOG.debug("Removing token at " + tokenKey); } try { db.delete(bytes(tokenKey)); } catch (DBException e) { throw new IOException(e); } }
public void delete(byte[] key) { if (getOptions() != null) { DB database = null; try { database = factory.open(this.leveldbStore.getSelectedFile(), getOptions()); database.delete(key); } catch (Exception e) { JOptionPane.showMessageDialog(pane, "Unable to open database:\n" + e); e.printStackTrace(); } finally { if (database != null) { try { database.close(); } catch (IOException e) { JOptionPane.showMessageDialog(pane, "Unable to close database:\n" + e); e.printStackTrace(); } } } } }