@Test public void testGetSizeOnOsd() throws Exception { String volumeName = "testGetSizeOnOsd"; testEnv.startAdditionalOSDs(3); client.createVolume(mrcAddress, auth, userCredentials, volumeName); AdminVolume volume = client.openVolume(volumeName, null, options); volume.start(); volume.setDefaultReplicationPolicy(userCredentials, "/", ReplicaUpdatePolicies.REPL_UPDATE_PC_WQRQ, 3, ReplicationFlags.setSequentialStrategy(0)); AdminFileHandle fileHandle = volume.openFile( userCredentials, "/test.txt", SYSTEM_V_FCNTL.SYSTEM_V_FCNTL_H_O_CREAT.getNumber() | SYSTEM_V_FCNTL.SYSTEM_V_FCNTL_H_O_RDWR.getNumber(), 0777); String firstReplicaUuid = fileHandle.getReplica(0).getOsdUuids(0); String content = ""; for (int i = 0; i < 12000; i++) { content = content.concat("Hello World "); } byte[] bytesIn = content.getBytes(); int length = bytesIn.length; testEnv.stopOSD(firstReplicaUuid); fileHandle.write(userCredentials, bytesIn, length, 0); fileHandle.close(); testEnv.startOSD(firstReplicaUuid); long size = 0; do { while (testEnv.getPrimary(fileHandle.getGlobalFileId()) != null) { Thread.sleep(5000); } size = fileHandle.getSizeOnOSD(); } while (testEnv.getPrimary(fileHandle.getGlobalFileId()).equals(firstReplicaUuid)); assertEquals(length, size); client.deleteVolume(auth, userCredentials, volumeName); }
@Override public long getSizeOnOSD() throws IOException { FileCredentials.Builder fcBuilder = FileCredentials.newBuilder(); fcBuilder.setXlocs(fileInfo.getXLocSet()); fcBuilder.setXcap(getXcap()); String fileId = Helper.extractGlobalFileIdFromXcap(fcBuilder.getXcap()); xtreemfs_internal_get_file_sizeRequest request = xtreemfs_internal_get_file_sizeRequest.newBuilder() .setFileCredentials(fcBuilder.build()).setFileId(fileId).build(); xtreemfs_internal_get_file_sizeResponse response = RPCCaller .<xtreemfs_internal_get_file_sizeRequest, xtreemfs_internal_get_file_sizeResponse> syncCall( SERVICES.OSD, RPCAuthentication.userService, RPCAuthentication.authNone, volumeOptions, uuidResolver, osdUuidIterator, false, request, new CallGenerator<xtreemfs_internal_get_file_sizeRequest, xtreemfs_internal_get_file_sizeResponse>() { @Override public RPCResponse<xtreemfs_internal_get_file_sizeResponse> executeCall(InetSocketAddress server, Auth authHeader, UserCredentials userCreds, xtreemfs_internal_get_file_sizeRequest input) throws IOException, PosixErrorException { return osdServiceClient.xtreemfs_internal_get_file_size(server, authHeader, userCreds, input); } }); assert (response != null); return response.getFileSize(); }
FileHandleImplementation implements FileHandle, AdminFileHandle { @Override public long getSizeOnOSD() throws IOException { FileCredentials.Builder fcBuilder = FileCredentials.newBuilder(); fcBuilder.setXlocs(fileInfo.getXLocSet()); fcBuilder.setXcap(getXcap()); String fileId = Helper.extractGlobalFileIdFromXcap(fcBuilder.getXcap()); xtreemfs_internal_get_file_sizeRequest request = xtreemfs_internal_get_file_sizeRequest.newBuilder() .setFileCredentials(fcBuilder.build()).setFileId(fileId).build(); xtreemfs_internal_get_file_sizeResponse response = RPCCaller .<xtreemfs_internal_get_file_sizeRequest, xtreemfs_internal_get_file_sizeResponse> syncCall( SERVICES.OSD, RPCAuthentication.userService, RPCAuthentication.authNone, volumeOptions, uuidResolver, osdUuidIterator, false, request, new CallGenerator<xtreemfs_internal_get_file_sizeRequest, xtreemfs_internal_get_file_sizeResponse>() { @Override public RPCResponse<xtreemfs_internal_get_file_sizeResponse> executeCall(InetSocketAddress server, Auth authHeader, UserCredentials userCreds, xtreemfs_internal_get_file_sizeRequest input) throws IOException, PosixErrorException { return osdServiceClient.xtreemfs_internal_get_file_size(server, authHeader, userCreds, input); } }); assert (response != null); return response.getFileSize(); } }
FileHandleImplementation implements FileHandle, AdminFileHandle { @Override public long getSizeOnOSD() throws IOException { FileCredentials.Builder fcBuilder = FileCredentials.newBuilder(); fcBuilder.setXlocs(fileInfo.getXLocSet()); fcBuilder.setXcap(getXcap()); String fileId = Helper.extractGlobalFileIdFromXcap(fcBuilder.getXcap()); xtreemfs_internal_get_file_sizeRequest request = xtreemfs_internal_get_file_sizeRequest.newBuilder() .setFileCredentials(fcBuilder.build()).setFileId(fileId).build(); xtreemfs_internal_get_file_sizeResponse response = RPCCaller .<xtreemfs_internal_get_file_sizeRequest, xtreemfs_internal_get_file_sizeResponse> syncCall( SERVICES.OSD, RPCAuthentication.userService, RPCAuthentication.authNone, volumeOptions, uuidResolver, osdUuidIterator, false, request, new CallGenerator<xtreemfs_internal_get_file_sizeRequest, xtreemfs_internal_get_file_sizeResponse>() { @Override public RPCResponse<xtreemfs_internal_get_file_sizeResponse> executeCall(InetSocketAddress server, Auth authHeader, UserCredentials userCreds, xtreemfs_internal_get_file_sizeRequest input) throws IOException, PosixErrorException { return osdServiceClient.xtreemfs_internal_get_file_size(server, authHeader, userCreds, input); } }); assert (response != null); return response.getFileSize(); } 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 { @Override public long getSizeOnOSD() throws IOException { FileCredentials.Builder fcBuilder = FileCredentials.newBuilder(); fcBuilder.setXlocs(fileInfo.getXLocSet()); fcBuilder.setXcap(getXcap()); String fileId = Helper.extractGlobalFileIdFromXcap(fcBuilder.getXcap()); xtreemfs_internal_get_file_sizeRequest request = xtreemfs_internal_get_file_sizeRequest.newBuilder() .setFileCredentials(fcBuilder.build()).setFileId(fileId).build(); xtreemfs_internal_get_file_sizeResponse response = RPCCaller .<xtreemfs_internal_get_file_sizeRequest, xtreemfs_internal_get_file_sizeResponse> syncCall( SERVICES.OSD, RPCAuthentication.userService, RPCAuthentication.authNone, volumeOptions, uuidResolver, osdUuidIterator, false, request, new CallGenerator<xtreemfs_internal_get_file_sizeRequest, xtreemfs_internal_get_file_sizeResponse>() { @Override public RPCResponse<xtreemfs_internal_get_file_sizeResponse> executeCall(InetSocketAddress server, Auth authHeader, UserCredentials userCreds, xtreemfs_internal_get_file_sizeRequest input) throws IOException, PosixErrorException { return osdServiceClient.xtreemfs_internal_get_file_size(server, authHeader, userCreds, input); } }); assert (response != null); return response.getFileSize(); } 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 { @Override public long getSizeOnOSD() throws IOException { FileCredentials.Builder fcBuilder = FileCredentials.newBuilder(); fcBuilder.setXlocs(fileInfo.getXLocSet()); fcBuilder.setXcap(getXcap()); String fileId = Helper.extractGlobalFileIdFromXcap(fcBuilder.getXcap()); xtreemfs_internal_get_file_sizeRequest request = xtreemfs_internal_get_file_sizeRequest.newBuilder() .setFileCredentials(fcBuilder.build()).setFileId(fileId).build(); xtreemfs_internal_get_file_sizeResponse response = RPCCaller .<xtreemfs_internal_get_file_sizeRequest, xtreemfs_internal_get_file_sizeResponse> syncCall( SERVICES.OSD, RPCAuthentication.userService, RPCAuthentication.authNone, volumeOptions, uuidResolver, osdUuidIterator, false, request, new CallGenerator<xtreemfs_internal_get_file_sizeRequest, xtreemfs_internal_get_file_sizeResponse>() { @Override public RPCResponse<xtreemfs_internal_get_file_sizeResponse> executeCall(InetSocketAddress server, Auth authHeader, UserCredentials userCreds, xtreemfs_internal_get_file_sizeRequest input) throws IOException, PosixErrorException { return osdServiceClient.xtreemfs_internal_get_file_size(server, authHeader, userCreds, input); } }); assert (response != null); return response.getFileSize(); } 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();  }