@Test public void testRemoveEmptyDirectory() { long reqId = 13; ms.mkdirs("/a/b/test_dir"); BinaryRawWriterEx message = createMessage(reqId, ModelStorateThinClientProcessor.PROCESSOR_ID, ModelStorateThinClientProcessor.Method.REMOVE); message.writeString("/a/b/test_dir"); ClientCustomQueryRequest req = new ClientCustomQueryRequest(toReader(message)); ClientResponse resp = req.process(connCtx); BinaryRawWriterEx out = createWriter(); resp.encode(connCtx, out); byte[] result = out.out().arrayCopy(); assertFalse(ms.exists("/a/b/test_dir")); assertTrue(ms.exists("/a/b")); assertArrayEquals(getExpectedMessageHeader(reqId).out().arrayCopy(), result); }
private ClientResponse mkdirs(long reqId, BinaryRawReader reader) { String path = reader.readString(); boolean onlyIfNotExists = reader.readBoolean(); return modelStorage.lockPaths(() -> { if (onlyIfNotExists && modelStorage.exists(path)) return error(reqId, "Directory already exists [path=" + path + "]"); modelStorage.mkdirs(path); return new ClientResponse(reqId); }, path); }
ModelStorateThinClientProcessor implements CustomQueryProcessor { private ClientResponse mkdirs(long reqId, BinaryRawReader reader) { String path = reader.readString(); boolean onlyIfNotExists = reader.readBoolean(); return modelStorage.lockPaths(() -> { if (onlyIfNotExists && modelStorage.exists(path)) return error(reqId, "Directory already exists [path=" + path + "]"); modelStorage.mkdirs(path); return new ClientResponse(reqId); }, path); } }
ModelStorateThinClientProcessor implements CustomQueryProcessor { private ClientResponse mkdirs(long reqId, BinaryRawReader reader) { String path = reader.readString(); boolean onlyIfNotExists = reader.readBoolean(); return modelStorage.lockPaths(() -> { if (onlyIfNotExists && modelStorage.exists(path)) return error(reqId, "Directory already exists [path=" + path + "]"); modelStorage.mkdirs(path); return new ClientResponse(reqId); }, path); } ModelStorateThinClientProcessor(ModelStorage modelStorage); }
ModelStorateThinClientProcessor implements CustomQueryProcessor { private ClientResponse mkdirs(long reqId, BinaryRawReader reader) { String path = reader.readString(); boolean onlyIfNotExists = reader.readBoolean(); return modelStorage.lockPaths(() -> { if (onlyIfNotExists && modelStorage.exists(path)) return error(reqId, "Directory already exists [path=" + path + "]"); modelStorage.mkdirs(path); return new ClientResponse(reqId); }, path); } ModelStorateThinClientProcessor(ModelStorage modelStorage); @Override ClientResponse call(long requestId, byte methodId, BinaryRawReader reader); @Override String id(); }
ModelStorateThinClientProcessor implements CustomQueryProcessor { private ClientResponse mkdirs(long reqId, BinaryRawReader reader) { String path = reader.readString(); boolean onlyIfNotExists = reader.readBoolean(); return modelStorage.lockPaths(() -> { if (onlyIfNotExists && modelStorage.exists(path)) return error(reqId, "Directory already exists [path=" + path + "]"); modelStorage.mkdirs(path); return new ClientResponse(reqId); }, path); } ModelStorateThinClientProcessor(ModelStorage modelStorage); @Override ClientResponse call(long requestId, byte methodId, BinaryRawReader reader); @Override String id(); static final String PROCESSOR_ID; }