@Override public void init(Configuration conf) throws Exception { fsWorkingPath = new Path(conf.get(YarnConfiguration.FS_NODE_LABELS_STORE_ROOT_DIR, getDefaultFSNodeLabelsRootDir())); setFileSystem(conf); // mkdir of root dir path if (!fs.exists(fsWorkingPath)) { fs.mkdirs(fsWorkingPath); } }
@Override public void init(Configuration conf, CommonNodeLabelsManager mgr) throws Exception { StoreSchema schema = new StoreSchema(EDITLOG_FILENAME, MIRROR_FILENAME); initStore(conf, new Path( conf.get(YarnConfiguration.FS_NODE_LABELS_STORE_ROOT_DIR, getDefaultFSNodeLabelsRootDir())), schema, mgr); }
@Override public void removeClusterNodeLabels(Collection<String> labels) throws IOException { ensureAppendEditlogFile(); editlogOs.writeInt(SerializedLogType.REMOVE_LABELS.ordinal()); ((RemoveFromClusterNodeLabelsRequestPBImpl) RemoveFromClusterNodeLabelsRequest.newInstance(Sets .newHashSet(labels.iterator()))).getProto().writeDelimitedTo(editlogOs); ensureCloseEditlogFile(); }
private void verifyMkdirsCount(FileSystemNodeLabelsStore store, boolean existsRetVal, int expectedNumOfCalls) throws Exception { Mockito.when(store.getFs().exists(Mockito.any( Path.class))).thenReturn(existsRetVal); store.init(conf, mgr); Mockito.verify(store.getFs(), Mockito.times( expectedNumOfCalls)).mkdirs(Mockito.any(Path .class)); } }
private void verifyMkdirsCount(FileSystemNodeLabelsStore store, boolean existsRetVal, int expectedNumOfCalls) throws Exception { Mockito.when(store.fs.exists(Mockito.any( Path.class))).thenReturn(existsRetVal); store.init(conf); Mockito.verify(store.fs,Mockito.times( expectedNumOfCalls)).mkdirs(Mockito.any(Path .class)); } }
protected void initNodeLabelStore(Configuration conf) throws Exception { this.store = new FileSystemNodeLabelsStore(this); this.store.init(conf); this.store.recover(); }
@After public void after() throws IOException { if (mgr.store instanceof FileSystemNodeLabelsStore) { FileSystemNodeLabelsStore fsStore = ((FileSystemNodeLabelsStore) mgr.store); fsStore.getFs().delete(fsStore.getFsWorkingPath(), true); } mgr.stop(); }
@Override public void removeClusterNodeLabels(Collection<String> labels) throws IOException { ensureAppendEditlogFile(); editlogOs.writeInt(SerializedLogType.REMOVE_LABELS.ordinal()); ((RemoveFromClusterNodeLabelsRequestPBImpl) RemoveFromClusterNodeLabelsRequest.newInstance(Sets .newHashSet(labels.iterator()))).getProto().writeDelimitedTo(editlogOs); ensureCloseEditlogFile(); }
private void verifyMkdirsCount(FileSystemNodeLabelsStore store, boolean existsRetVal, int expectedNumOfCalls) throws Exception { Mockito.when(store.fs.exists(Mockito.any( Path.class))).thenReturn(existsRetVal); store.init(conf); Mockito.verify(store.fs,Mockito.times( expectedNumOfCalls)).mkdirs(Mockito.any(Path .class)); } }
protected void initNodeLabelStore(Configuration conf) throws Exception { this.store = new FileSystemNodeLabelsStore(this); this.store.init(conf); this.store.recover(); }
@Override public void updateNodeToLabelsMappings( Map<NodeId, Set<String>> nodeToLabels) throws IOException { ensureAppendEditlogFile(); editlogOs.writeInt(SerializedLogType.NODE_TO_LABELS.ordinal()); ((ReplaceLabelsOnNodeRequestPBImpl) ReplaceLabelsOnNodeRequest .newInstance(nodeToLabels)).getProto().writeDelimitedTo(editlogOs); ensureCloseEditlogFile(); }
@Override public void init(Configuration conf) throws Exception { fsWorkingPath = new Path(conf.get(YarnConfiguration.FS_NODE_LABELS_STORE_ROOT_DIR, getDefaultFSNodeLabelsRootDir())); setFileSystem(conf); // mkdir of root dir path if (!fs.exists(fsWorkingPath)) { fs.mkdirs(fsWorkingPath); } }
@Override public void storeNewClusterNodeLabels(Set<String> labels) throws IOException { ensureAppendEditlogFile(); editlogOs.writeInt(SerializedLogType.ADD_LABELS.ordinal()); ((AddToClusterNodeLabelsRequestPBImpl) AddToClusterNodeLabelsRequest.newInstance(labels)).getProto() .writeDelimitedTo(editlogOs); ensureCloseEditlogFile(); }
@Override public void updateNodeToLabelsMappings( Map<NodeId, Set<String>> nodeToLabels) throws IOException { ensureAppendEditlogFile(); editlogOs.writeInt(SerializedLogType.NODE_TO_LABELS.ordinal()); ((ReplaceLabelsOnNodeRequestPBImpl) ReplaceLabelsOnNodeRequest .newInstance(nodeToLabels)).getProto().writeDelimitedTo(editlogOs); ensureCloseEditlogFile(); }
@Override public void storeNewClusterNodeLabels(Set<String> labels) throws IOException { ensureAppendEditlogFile(); editlogOs.writeInt(SerializedLogType.ADD_LABELS.ordinal()); ((AddToClusterNodeLabelsRequestPBImpl) AddToClusterNodeLabelsRequest.newInstance(labels)).getProto() .writeDelimitedTo(editlogOs); ensureCloseEditlogFile(); }