@Test public void testWriteBackFileSize() throws Exception { String volumeName = "testWriteBackFileSize"; String fileName = "testfile"; int flags = SYSTEM_V_FCNTL.SYSTEM_V_FCNTL_H_O_CREAT.getNumber() | SYSTEM_V_FCNTL.SYSTEM_V_FCNTL_H_O_RDWR.getNumber(); Client client = ClientFactory.createClient(ClientType.JAVA, dirAddress, userCredentials, null, options); client.start(); client.createVolume(mrcAddress, auth, userCredentials, volumeName); Volume volume = client.openVolume(volumeName, null, options); FileHandleImplementation fileHandle = (FileHandleImplementation) volume.openFile(userCredentials, fileName, flags, 0777); OSDWriteResponse.Builder responseBuilder = OSDWriteResponse.newBuilder(); responseBuilder.setSizeInBytes(13337); responseBuilder.setTruncateEpoch(20); OSDWriteResponse response = responseBuilder.build(); fileHandle.writeBackFileSize(response, false); RPCResponse<getattrResponse> r = mrcClient.getattr(testEnv.getMRCAddress(), auth, userCredentials, volumeName, fileName, 0l); getattrResponse response2 = r.get(); assertEquals(response.getSizeInBytes(), response2.getStbuf().getSize()); assertEquals(response.getTruncateEpoch(), response2.getStbuf().getTruncateEpoch()); r.freeBuffers(); }
protected void writeBackFileSize(OSDWriteResponse response, boolean closeFile) throws IOException, PosixErrorException, AddressToUUIDNotFoundException { long fileId = 0; fileId = Helper.extractFileIdFromXcap(getXcap()); if (Logging.isDebug()) { Logging.logMessage(Logging.LEVEL_DEBUG, Category.misc, this, "WriteBackFileSize: fileId: %s #bytes: %s close file?: %s", fileId, response.getSizeInBytes(), closeFile); } xtreemfs_update_file_sizeRequest.Builder requestBuilder = xtreemfs_update_file_sizeRequest.newBuilder(); requestBuilder.setXcap(getXcap()); requestBuilder.setOsdWriteResponse(response.toBuilder().build()); requestBuilder.setCloseFile(closeFile); RPCCaller.<xtreemfs_update_file_sizeRequest, timestampResponse> syncCall(SERVICES.MRC, userCredentialsBogus, authBogus, volumeOptions, uuidResolver, mrcUuidIterator, false, requestBuilder.build(), new CallGenerator<xtreemfs_update_file_sizeRequest, timestampResponse>() { @Override public RPCResponse<timestampResponse> executeCall(InetSocketAddress server, Auth authHeader, UserCredentials userCreds, xtreemfs_update_file_sizeRequest input) throws IOException { return mrcServiceClient.xtreemfs_update_file_size(server, authHeader, userCreds, input); } }); }
FileHandleImplementation implements FileHandle, AdminFileHandle { protected void writeBackFileSize(OSDWriteResponse response, boolean closeFile) throws IOException, PosixErrorException, AddressToUUIDNotFoundException { long fileId = 0; fileId = Helper.extractFileIdFromXcap(getXcap()); if (Logging.isDebug()) { Logging.logMessage(Logging.LEVEL_DEBUG, Category.misc, this, "WriteBackFileSize: fileId: %s #bytes: %s close file?: %s", fileId, response.getSizeInBytes(), closeFile); } xtreemfs_update_file_sizeRequest.Builder requestBuilder = xtreemfs_update_file_sizeRequest.newBuilder(); requestBuilder.setXcap(getXcap()); requestBuilder.setOsdWriteResponse(response.toBuilder().build()); requestBuilder.setCloseFile(closeFile); RPCCaller.<xtreemfs_update_file_sizeRequest, timestampResponse> syncCall(SERVICES.MRC, userCredentialsBogus, authBogus, volumeOptions, uuidResolver, mrcUuidIterator, false, requestBuilder.build(), new CallGenerator<xtreemfs_update_file_sizeRequest, timestampResponse>() { @Override public RPCResponse<timestampResponse> executeCall(InetSocketAddress server, Auth authHeader, UserCredentials userCreds, xtreemfs_update_file_sizeRequest input) throws IOException { return mrcServiceClient.xtreemfs_update_file_size(server, authHeader, userCreds, input); } }); } }
FileHandleImplementation implements FileHandle, AdminFileHandle { protected void writeBackFileSize(OSDWriteResponse response, boolean closeFile) throws IOException, PosixErrorException, AddressToUUIDNotFoundException { long fileId = 0; fileId = Helper.extractFileIdFromXcap(getXcap()); if (Logging.isDebug()) { Logging.logMessage(Logging.LEVEL_DEBUG, Category.misc, this, "WriteBackFileSize: fileId: %s #bytes: %s close file?: %s", fileId, response.getSizeInBytes(), closeFile); } xtreemfs_update_file_sizeRequest.Builder requestBuilder = xtreemfs_update_file_sizeRequest.newBuilder(); requestBuilder.setXcap(getXcap()); requestBuilder.setOsdWriteResponse(response.toBuilder().build()); requestBuilder.setCloseFile(closeFile); RPCCaller.<xtreemfs_update_file_sizeRequest, timestampResponse> syncCall(SERVICES.MRC, userCredentialsBogus, authBogus, volumeOptions, uuidResolver, mrcUuidIterator, false, requestBuilder.build(), new CallGenerator<xtreemfs_update_file_sizeRequest, timestampResponse>() { @Override public RPCResponse<timestampResponse> executeCall(InetSocketAddress server, Auth authHeader, UserCredentials userCreds, xtreemfs_update_file_sizeRequest input) throws IOException { return mrcServiceClient.xtreemfs_update_file_size(server, authHeader, userCreds, input); } }); } FileHandleImplementation(VolumeImplementation volume, String clientUuid, FileInfo fileInfo, XCap xcap,
            UUIDIterator mrcUuidIterator, UUIDIterator osdUuidIterator, UUIDResolver uuidResolver,
            MRCServiceClient mrcServiceClient, OSDServiceClient osdServiceClient,
            Map<StripingPolicyType, StripeTranslator> stripeTranslators, boolean asyncWritesEnabled, Options options,
            Auth authBogus, UserCredentials userCredentialsBogus); }
FileHandleImplementation implements FileHandle, AdminFileHandle { protected void writeBackFileSize(OSDWriteResponse response, boolean closeFile) throws IOException, PosixErrorException, AddressToUUIDNotFoundException { long fileId = 0; fileId = Helper.extractFileIdFromXcap(getXcap()); if (Logging.isDebug()) { Logging.logMessage(Logging.LEVEL_DEBUG, Category.misc, this, "WriteBackFileSize: fileId: %s #bytes: %s close file?: %s", fileId, response.getSizeInBytes(), closeFile); } xtreemfs_update_file_sizeRequest.Builder requestBuilder = xtreemfs_update_file_sizeRequest.newBuilder(); requestBuilder.setXcap(getXcap()); requestBuilder.setOsdWriteResponse(response.toBuilder().build()); requestBuilder.setCloseFile(closeFile); RPCCaller.<xtreemfs_update_file_sizeRequest, timestampResponse> syncCall(SERVICES.MRC, userCredentialsBogus, authBogus, volumeOptions, uuidResolver, mrcUuidIterator, false, requestBuilder.build(), new CallGenerator<xtreemfs_update_file_sizeRequest, timestampResponse>() { @Override public RPCResponse<timestampResponse> executeCall(InetSocketAddress server, Auth authHeader, UserCredentials userCreds, xtreemfs_update_file_sizeRequest input) throws IOException { return mrcServiceClient.xtreemfs_update_file_size(server, authHeader, userCreds, input); } }); } FileHandleImplementation(VolumeImplementation volume, String clientUuid, FileInfo fileInfo, XCap xcap,
            UUIDIterator mrcUuidIterator, UUIDIterator osdUuidIterator, UUIDResolver uuidResolver,
            MRCServiceClient mrcServiceClient, OSDServiceClient osdServiceClient,
            Map<StripingPolicyType, StripeTranslator> stripeTranslators, boolean asyncWritesEnabled, Options options,
            Auth authBogus, UserCredentials userCredentialsBogus); @Override int read(UserCredentials userCredentials, byte[] data, int count, long offset); @Override int read(final UserCredentials userCredentials, final byte[] data, final int dataOffset, final int count,
            final long offset); @Override synchronized int write(UserCredentials userCredentials, byte[] data, int count, long offset); @Override synchronized int write(UserCredentials userCredentials, byte[] data, int dataOffset, int count, long offset); @Override void flush(); @Override void truncate(UserCredentials userCredentials, long newFileSize); @Override void truncate(UserCredentials userCredentials, long newFileSize, boolean updateOnlyMRC); @Override Stat getAttr(UserCredentials userCredentials); @Override Lock acquireLock(final UserCredentials userCredentials, final int processId, final long offset,
            final long length, final boolean exclusive, final boolean waitForLock); @Override Lock checkLock(final UserCredentials userCredentials, final int processId, final long offset,
            final long length, final boolean exclusive); @Override void releaseLock(final UserCredentials userCredentials, final int processId, final long offset,
            final long length, final boolean exclusive); @Override void releaseLock(UserCredentials userCredentials, Lock lock); @Override void releaseLockOfProcess(int processId); @Override void pingReplica(UserCredentials userCredentials, String osdUuid); @Override void close(); @Override String getGlobalFileId(); @Override List<Replica> getReplicasList(); @Override Replica getReplica(int replicaIndex); @Override StripingPolicy getStripingPolicy(); @Override StripingPolicy getStripingPolicy(int replicaIndex); @Override String getReplicaUpdatePolicy(); @Override long getNumObjects(UserCredentials userCredentials); @Override boolean checkAndMarkIfReadOnlyReplicaComplete(int replicaIndex, UserCredentials userCredentials); @Override int checkObjectAndGetSize(int replicaIndex, long objectNo); @Override long getSizeOnOSD(); @Override void repairObject(int replicaIndex, long objectNo); @Override String getLastOSDAddress(); }
FileHandleImplementation implements FileHandle, AdminFileHandle { protected void writeBackFileSize(OSDWriteResponse response, boolean closeFile) throws IOException, PosixErrorException, AddressToUUIDNotFoundException { long fileId = 0; fileId = Helper.extractFileIdFromXcap(getXcap()); if (Logging.isDebug()) { Logging.logMessage(Logging.LEVEL_DEBUG, Category.misc, this, "WriteBackFileSize: fileId: %s #bytes: %s close file?: %s", fileId, response.getSizeInBytes(), closeFile); } xtreemfs_update_file_sizeRequest.Builder requestBuilder = xtreemfs_update_file_sizeRequest.newBuilder(); requestBuilder.setXcap(getXcap()); requestBuilder.setOsdWriteResponse(response.toBuilder().build()); requestBuilder.setCloseFile(closeFile); RPCCaller.<xtreemfs_update_file_sizeRequest, timestampResponse> syncCall(SERVICES.MRC, userCredentialsBogus, authBogus, volumeOptions, uuidResolver, mrcUuidIterator, false, requestBuilder.build(), new CallGenerator<xtreemfs_update_file_sizeRequest, timestampResponse>() { @Override public RPCResponse<timestampResponse> executeCall(InetSocketAddress server, Auth authHeader, UserCredentials userCreds, xtreemfs_update_file_sizeRequest input) throws IOException { return mrcServiceClient.xtreemfs_update_file_size(server, authHeader, userCreds, input); } }); } FileHandleImplementation(VolumeImplementation volume, String clientUuid, FileInfo fileInfo, XCap xcap,
            UUIDIterator mrcUuidIterator, UUIDIterator osdUuidIterator, UUIDResolver uuidResolver,
            MRCServiceClient mrcServiceClient, OSDServiceClient osdServiceClient,
            Map<StripingPolicyType, StripeTranslator> stripeTranslators, boolean asyncWritesEnabled, Options options,
            Auth authBogus, UserCredentials userCredentialsBogus); @Override int read(UserCredentials userCredentials, byte[] data, int count, long offset); @Override int read(final UserCredentials userCredentials, final byte[] data, final int dataOffset, final int count,
            final long offset); @Override synchronized int write(UserCredentials userCredentials, byte[] data, int count, long offset); @Override synchronized int write(UserCredentials userCredentials, byte[] data, int dataOffset, int count, long offset); @Override void flush(); @Override void truncate(UserCredentials userCredentials, long newFileSize); @Override void truncate(UserCredentials userCredentials, long newFileSize, boolean updateOnlyMRC); @Override Stat getAttr(UserCredentials userCredentials); @Override Lock acquireLock(final UserCredentials userCredentials, final int processId, final long offset,
            final long length, final boolean exclusive, final boolean waitForLock); @Override Lock checkLock(final UserCredentials userCredentials, final int processId, final long offset,
            final long length, final boolean exclusive); @Override void releaseLock(final UserCredentials userCredentials, final int processId, final long offset,
            final long length, final boolean exclusive); @Override void releaseLock(UserCredentials userCredentials, Lock lock); @Override void releaseLockOfProcess(int processId); @Override void pingReplica(UserCredentials userCredentials, String osdUuid); @Override void close(); @Override String getGlobalFileId(); @Override List<Replica> getReplicasList(); @Override Replica getReplica(int replicaIndex); @Override StripingPolicy getStripingPolicy(); @Override StripingPolicy getStripingPolicy(int replicaIndex); @Override String getReplicaUpdatePolicy(); @Override long getNumObjects(UserCredentials userCredentials); @Override boolean checkAndMarkIfReadOnlyReplicaComplete(int replicaIndex, UserCredentials userCredentials); @Override int checkObjectAndGetSize(int replicaIndex, long objectNo); @Override long getSizeOnOSD(); @Override void repairObject(int replicaIndex, long objectNo); @Override String getLastOSDAddress();  }