Tom, please revert this commit and do a commit that doesn’t include a billion lines of formatting change and includes the actual change? (
Cheers, Chris On 12/12/17, 2:56 PM, "magicaltr...@apache.org" <magicaltr...@apache.org> wrote: Repository: oodt Updated Branches: refs/heads/development bfb78c9a0 -> 82b522516 close connection to release client Project: http://git-wip-us.apache.org/repos/asf/oodt/repo Commit: http://git-wip-us.apache.org/repos/asf/oodt/commit/82b52251 Tree: http://git-wip-us.apache.org/repos/asf/oodt/tree/82b52251 Diff: http://git-wip-us.apache.org/repos/asf/oodt/diff/82b52251 Branch: refs/heads/development Commit: 82b5225162f78ee092e473218769bea61e3e510f Parents: bfb78c9 Author: Tom Barber <tom.bar...@jpl.nasa.gov> Authored: Tue Dec 12 22:56:39 2017 +0000 Committer: Tom Barber <tom.bar...@jpl.nasa.gov> Committed: Tue Dec 12 22:56:39 2017 +0000 ---------------------------------------------------------------------- .../filemgr/system/AvroFileManagerClient.java | 320 +++++++++++++++++-- 1 file changed, 301 insertions(+), 19 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/oodt/blob/82b52251/filemgr/src/main/java/org/apache/oodt/cas/filemgr/system/AvroFileManagerClient.java ---------------------------------------------------------------------- diff --git a/filemgr/src/main/java/org/apache/oodt/cas/filemgr/system/AvroFileManagerClient.java b/filemgr/src/main/java/org/apache/oodt/cas/filemgr/system/AvroFileManagerClient.java index 3feda3d..043330a 100644 --- a/filemgr/src/main/java/org/apache/oodt/cas/filemgr/system/AvroFileManagerClient.java +++ b/filemgr/src/main/java/org/apache/oodt/cas/filemgr/system/AvroFileManagerClient.java @@ -17,45 +17,46 @@ package org.apache.oodt.cas.filemgr.system; +import java.io.IOException; +import java.net.InetSocketAddress; +import java.net.URL; +import java.nio.ByteBuffer; +import java.util.ArrayList; +import java.util.List; +import java.util.logging.Level; +import java.util.logging.Logger; import org.apache.avro.AvroRemoteException; import org.apache.avro.ipc.NettyTransceiver; import org.apache.avro.ipc.Transceiver; import org.apache.avro.ipc.specific.SpecificRequestor; import org.apache.oodt.cas.filemgr.datatransfer.DataTransfer; +import org.apache.oodt.cas.filemgr.exceptions.FileManagerException; import org.apache.oodt.cas.filemgr.structs.Element; -import org.apache.oodt.cas.filemgr.structs.Product; import org.apache.oodt.cas.filemgr.structs.FileTransferStatus; +import org.apache.oodt.cas.filemgr.structs.Product; import org.apache.oodt.cas.filemgr.structs.ProductPage; import org.apache.oodt.cas.filemgr.structs.ProductType; -import org.apache.oodt.cas.filemgr.structs.Reference; import org.apache.oodt.cas.filemgr.structs.Query; +import org.apache.oodt.cas.filemgr.structs.Reference; +import org.apache.oodt.cas.filemgr.structs.avrotypes.AvroElement; import org.apache.oodt.cas.filemgr.structs.avrotypes.AvroFileManager; import org.apache.oodt.cas.filemgr.structs.avrotypes.AvroFileTransferStatus; import org.apache.oodt.cas.filemgr.structs.avrotypes.AvroProduct; -import org.apache.oodt.cas.filemgr.structs.avrotypes.AvroElement; -import org.apache.oodt.cas.filemgr.structs.avrotypes.AvroQueryResult; import org.apache.oodt.cas.filemgr.structs.avrotypes.AvroProductType; +import org.apache.oodt.cas.filemgr.structs.avrotypes.AvroQueryResult; import org.apache.oodt.cas.filemgr.structs.avrotypes.AvroReference; -import org.apache.oodt.cas.filemgr.structs.exceptions.RepositoryManagerException; import org.apache.oodt.cas.filemgr.structs.exceptions.CatalogException; +import org.apache.oodt.cas.filemgr.structs.exceptions.ConnectionException; import org.apache.oodt.cas.filemgr.structs.exceptions.DataTransferException; +import org.apache.oodt.cas.filemgr.structs.exceptions.RepositoryManagerException; import org.apache.oodt.cas.filemgr.structs.exceptions.ValidationLayerException; import org.apache.oodt.cas.filemgr.structs.exceptions.VersioningException; -import org.apache.oodt.cas.filemgr.structs.exceptions.ConnectionException; import org.apache.oodt.cas.filemgr.structs.query.ComplexQuery; import org.apache.oodt.cas.filemgr.structs.query.QueryResult; import org.apache.oodt.cas.filemgr.util.AvroTypeFactory; import org.apache.oodt.cas.filemgr.util.GenericFileManagerObjectFactory; import org.apache.oodt.cas.filemgr.versioning.Versioner; import org.apache.oodt.cas.metadata.Metadata; -import java.io.IOException; -import java.net.InetSocketAddress; -import java.net.URL; -import java.nio.ByteBuffer; -import java.util.ArrayList; -import java.util.List; -import java.util.logging.Level; -import java.util.logging.Logger; /** * @author radu @@ -142,8 +143,13 @@ public class AvroFileManagerClient implements FileManagerClient { try { success = proxy.transferringProduct(AvroTypeFactory.getAvroProduct(product)); } catch (AvroRemoteException e) { - e.printStackTrace(); throw new DataTransferException(e.getMessage()); + } finally { + try { + this.client.close(); + } catch (IOException e) { + throw new DataTransferException(e.getMessage()); + } } return success; @@ -156,6 +162,12 @@ public class AvroFileManagerClient implements FileManagerClient { success = proxy.removeProductTransferStatus(AvroTypeFactory.getAvroProduct(product)); } catch (AvroRemoteException e) { throw new DataTransferException(e.getMessage()); + } finally { + try { + this.client.close(); + } catch (IOException e) { + throw new DataTransferException(e.getMessage()); + } } return success; } @@ -167,6 +179,12 @@ public class AvroFileManagerClient implements FileManagerClient { success = this.proxy.isTransferComplete(AvroTypeFactory.getAvroProduct(product)); } catch (AvroRemoteException e) { throw new DataTransferException(e.getMessage()); + } finally { + try { + this.client.close(); + } catch (IOException e) { + throw new DataTransferException(e.getMessage()); + } } return success; } @@ -178,6 +196,12 @@ public class AvroFileManagerClient implements FileManagerClient { success = this.proxy.moveProduct(AvroTypeFactory.getAvroProduct(product), newPath); } catch (AvroRemoteException e) { throw new DataTransferException(e.getMessage()); + } finally { + try { + this.client.close(); + } catch (IOException e) { + throw new DataTransferException(e.getMessage()); + } } return success; } @@ -189,6 +213,12 @@ public class AvroFileManagerClient implements FileManagerClient { success = this.proxy.modifyProduct(AvroTypeFactory.getAvroProduct(product)); } catch (AvroRemoteException e) { throw new CatalogException(e.getMessage()); + } finally { + try { + this.client.close(); + } catch (IOException e) { + throw new CatalogException(e.getMessage()); + } } return success; } @@ -200,6 +230,12 @@ public class AvroFileManagerClient implements FileManagerClient { success = this.proxy.removeProduct(AvroTypeFactory.getAvroProduct(product)); } catch (AvroRemoteException e) { throw new CatalogException(e.getMessage()); + } finally { + try { + this.client.close(); + } catch (IOException e) { + throw new CatalogException(e.getMessage()); + } } return success; } @@ -210,6 +246,12 @@ public class AvroFileManagerClient implements FileManagerClient { return AvroTypeFactory.getFileTransferStatus(this.proxy.getCurrentFileTransfer()); } catch (AvroRemoteException e) { throw new DataTransferException(e.getMessage()); + } finally { + try { + this.client.close(); + } catch (IOException e) { + throw new DataTransferException(e.getMessage()); + } } } @@ -222,6 +264,12 @@ public class AvroFileManagerClient implements FileManagerClient { } } catch (AvroRemoteException e) { throw new DataTransferException(e.getMessage()); + } finally { + try { + this.client.close(); + } catch (IOException e) { + throw new DataTransferException(e.getMessage()); + } } return fileTransferStatuses; } @@ -232,6 +280,12 @@ public class AvroFileManagerClient implements FileManagerClient { return this.proxy.getProductPctTransferred(AvroTypeFactory.getAvroProduct(product)); } catch (AvroRemoteException e) { throw new DataTransferException(e.getMessage()); + } finally { + try { + this.client.close(); + } catch (IOException e) { + throw new DataTransferException(e.getMessage()); + } } } @@ -241,6 +295,12 @@ public class AvroFileManagerClient implements FileManagerClient { return this.proxy.getRefPctTransferred(AvroTypeFactory.getAvroReference(reference)); } catch (AvroRemoteException e) { throw new DataTransferException(e.getMessage()); + } finally { + try { + this.client.close(); + } catch (IOException e) { + throw new DataTransferException(e.getMessage()); + } } } @@ -255,6 +315,12 @@ public class AvroFileManagerClient implements FileManagerClient { )); } catch (AvroRemoteException e) { throw new CatalogException(e.getMessage()); + } finally { + try { + this.client.close(); + } catch (IOException e) { + throw new CatalogException(e.getMessage()); + } } } @@ -264,6 +330,12 @@ public class AvroFileManagerClient implements FileManagerClient { return AvroTypeFactory.getProductPage(this.proxy.getFirstPage(AvroTypeFactory.getAvroProductType(type))); } catch (AvroRemoteException e) { throw new CatalogException(e.getMessage()); + } finally { + try { + this.client.close(); + } catch (IOException e) { + throw new CatalogException(e.getMessage()); + } } } @@ -273,6 +345,12 @@ public class AvroFileManagerClient implements FileManagerClient { return AvroTypeFactory.getProductPage(this.proxy.getLastPage(AvroTypeFactory.getAvroProductType(type))); } catch (AvroRemoteException e) { throw new CatalogException(e.getMessage()); + } finally { + try { + this.client.close(); + } catch (IOException e) { + throw new CatalogException(e.getMessage()); + } } } @@ -285,6 +363,12 @@ public class AvroFileManagerClient implements FileManagerClient { )); } catch (AvroRemoteException e) { throw new CatalogException(e.getMessage()); + } finally { + try { + this.client.close(); + } catch (IOException e) { + throw new CatalogException(e.getMessage()); + } } } @@ -297,6 +381,12 @@ public class AvroFileManagerClient implements FileManagerClient { )); } catch (AvroRemoteException e) { throw new CatalogException(e.getMessage()); + } finally { + try { + this.client.close(); + } catch (IOException e) { + throw new CatalogException(e.getMessage()); + } } } @@ -306,6 +396,12 @@ public class AvroFileManagerClient implements FileManagerClient { return this.proxy.addProductType(AvroTypeFactory.getAvroProductType(type)); } catch (AvroRemoteException e) { throw new RepositoryManagerException(e.getMessage()); + } finally { + try { + this.client.close(); + } catch (IOException e) { + throw new RepositoryManagerException(e.getMessage()); + } } } @@ -315,6 +411,12 @@ public class AvroFileManagerClient implements FileManagerClient { return this.proxy.hasProduct(productName); } catch (AvroRemoteException e) { throw new CatalogException(e.getMessage()); + } finally { + try { + this.client.close(); + } catch (IOException e) { + throw new CatalogException(e.getMessage()); + } } } @@ -324,6 +426,12 @@ public class AvroFileManagerClient implements FileManagerClient { return this.proxy.getNumProducts(AvroTypeFactory.getAvroProductType(type)); } catch (AvroRemoteException e) { throw new CatalogException(e.getMessage()); + } finally { + try { + this.client.close(); + } catch (IOException e) { + throw new CatalogException(e.getMessage()); + } } } @@ -336,6 +444,12 @@ public class AvroFileManagerClient implements FileManagerClient { } } catch (AvroRemoteException e) { throw new CatalogException(e.getMessage()); + } finally { + try { + this.client.close(); + } catch (IOException e) { + throw new CatalogException(e.getMessage()); + } } return products; } @@ -349,6 +463,12 @@ public class AvroFileManagerClient implements FileManagerClient { } } catch (AvroRemoteException e) { throw new CatalogException(e.getMessage()); + } finally { + try { + this.client.close(); + } catch (IOException e) { + throw new CatalogException(e.getMessage()); + } } return products; } @@ -359,6 +479,12 @@ public class AvroFileManagerClient implements FileManagerClient { this.proxy.setProductTransferStatus(AvroTypeFactory.getAvroProduct(product)); } catch (AvroRemoteException e) { throw new CatalogException(e.getMessage()); + } finally { + try { + this.client.close(); + } catch (IOException e) { + throw new CatalogException(e.getMessage()); + } } } @@ -368,6 +494,12 @@ public class AvroFileManagerClient implements FileManagerClient { this.proxy.addProductReferences(AvroTypeFactory.getAvroProduct(product)); } catch (AvroRemoteException e) { throw new CatalogException(e.getMessage()); + } finally { + try { + this.client.close(); + } catch (IOException e) { + throw new CatalogException(e.getMessage()); + } } } @@ -378,6 +510,12 @@ public class AvroFileManagerClient implements FileManagerClient { AvroTypeFactory.getAvroMetadata(metadata)); } catch (AvroRemoteException e) { throw new CatalogException(e.getMessage()); + } finally { + try { + this.client.close(); + } catch (IOException e) { + throw new CatalogException(e.getMessage()); + } } } @@ -391,6 +529,12 @@ public class AvroFileManagerClient implements FileManagerClient { ); } catch (AvroRemoteException e) { throw new CatalogException(e.getMessage()); + } finally { + try { + this.client.close(); + } catch (IOException e) { + throw new CatalogException(e.getMessage()); + } } } @@ -400,6 +544,12 @@ public class AvroFileManagerClient implements FileManagerClient { return this.proxy.catalogProduct(AvroTypeFactory.getAvroProduct(product)); } catch (AvroRemoteException e) { throw new CatalogException(e.getMessage()); + } finally { + try { + this.client.close(); + } catch (IOException e) { + throw new CatalogException(e.getMessage()); + } } } @@ -409,6 +559,12 @@ public class AvroFileManagerClient implements FileManagerClient { return AvroTypeFactory.getMetadata(this.proxy.getMetadata(AvroTypeFactory.getAvroProduct(product))); } catch (AvroRemoteException e) { throw new CatalogException(e.getMessage()); + } finally { + try { + this.client.close(); + } catch (IOException e) { + throw new CatalogException(e.getMessage()); + } } } @@ -419,6 +575,12 @@ public class AvroFileManagerClient implements FileManagerClient { this.proxy.getReducedMetadata(AvroTypeFactory.getAvroProduct(product), (List<String>) elements)); } catch (AvroRemoteException e) { throw new CatalogException(e.getMessage()); + } finally { + try { + this.client.close(); + } catch (IOException e) { + throw new CatalogException(e.getMessage()); + } } } @@ -428,6 +590,12 @@ public class AvroFileManagerClient implements FileManagerClient { return this.proxy.removeFile(filePath); } catch (AvroRemoteException e) { throw new DataTransferException(e.getMessage()); + } finally { + try { + this.client.close(); + } catch (IOException e) { + throw new DataTransferException(e.getMessage()); + } } } @@ -437,6 +605,12 @@ public class AvroFileManagerClient implements FileManagerClient { return this.proxy.retrieveFile(filePath, offset, numBytes).array(); } catch (AvroRemoteException e) { throw new DataTransferException(e.getMessage()); + } finally { + try { + this.client.close(); + } catch (IOException e) { + throw new DataTransferException(e.getMessage()); + } } } @@ -446,6 +620,12 @@ public class AvroFileManagerClient implements FileManagerClient { this.proxy.transferFile(filePath, ByteBuffer.wrap(fileData), offset, numBytes); } catch (AvroRemoteException e) { throw new DataTransferException(e.getMessage()); + } finally { + try { + this.client.close(); + } catch (IOException e) { + throw new DataTransferException(e.getMessage()); + } } } @@ -461,6 +641,12 @@ public class AvroFileManagerClient implements FileManagerClient { } catch (AvroRemoteException e) { throw new CatalogException(e.getMessage()); + } finally { + try { + this.client.close(); + } catch (IOException e) { + throw new CatalogException(e.getMessage()); + } } } @@ -474,6 +660,12 @@ public class AvroFileManagerClient implements FileManagerClient { } } catch (AvroRemoteException e) { throw new ValidationLayerException(e.getMessage()); + } finally { + try { + this.client.close(); + } catch (IOException e) { + throw new ValidationLayerException(e.getMessage()); + } } return products; } @@ -484,6 +676,12 @@ public class AvroFileManagerClient implements FileManagerClient { return AvroTypeFactory.getElement(this.proxy.getElementById(elementId)); } catch (AvroRemoteException e) { throw new ValidationLayerException(e.getMessage()); + } finally { + try { + this.client.close(); + } catch (IOException e) { + throw new ValidationLayerException(e.getMessage()); + } } } @@ -493,6 +691,12 @@ public class AvroFileManagerClient implements FileManagerClient { return AvroTypeFactory.getElement(this.proxy.getElementByName(elementName)); } catch (AvroRemoteException e) { throw new ValidationLayerException(e.getMessage()); + } finally { + try { + this.client.close(); + } catch (IOException e) { + throw new ValidationLayerException(e.getMessage()); + } } } @@ -506,6 +710,12 @@ public class AvroFileManagerClient implements FileManagerClient { } } catch (AvroRemoteException e) { throw new CatalogException(e.getMessage()); + } finally { + try { + this.client.close(); + } catch (IOException e) { + throw new CatalogException(e.getMessage()); + } } return queryResults; } @@ -519,6 +729,12 @@ public class AvroFileManagerClient implements FileManagerClient { } } catch (AvroRemoteException e) { throw new CatalogException(e.getMessage()); + } finally { + try { + this.client.close(); + } catch (IOException e) { + throw new CatalogException(e.getMessage()); + } } return products; } @@ -529,6 +745,12 @@ public class AvroFileManagerClient implements FileManagerClient { return AvroTypeFactory.getProductType(this.proxy.getProductTypeByName(productTypeName)); } catch (AvroRemoteException e) { throw new RepositoryManagerException(e.getMessage()); + } finally { + try { + this.client.close(); + } catch (IOException e) { + throw new RepositoryManagerException(e.getMessage()); + } } } @@ -538,6 +760,12 @@ public class AvroFileManagerClient implements FileManagerClient { return AvroTypeFactory.getProductType(this.proxy.getProductTypeById(productTypeId)); } catch (AvroRemoteException e) { throw new RepositoryManagerException(e.getMessage()); + } finally { + try { + this.client.close(); + } catch (IOException e) { + throw new RepositoryManagerException(e.getMessage()); + } } } @@ -550,6 +778,12 @@ public class AvroFileManagerClient implements FileManagerClient { } } catch (AvroRemoteException e) { throw new RepositoryManagerException(e.getMessage()); + } finally { + try { + this.client.close(); + } catch (IOException e) { + throw new RepositoryManagerException(e.getMessage()); + } } return productTypes; } @@ -563,6 +797,12 @@ public class AvroFileManagerClient implements FileManagerClient { } } catch (AvroRemoteException e) { throw new CatalogException(e.getMessage()); + } finally { + try { + this.client.close(); + } catch (IOException e) { + throw new CatalogException(e.getMessage()); + } } return references; } @@ -573,6 +813,12 @@ public class AvroFileManagerClient implements FileManagerClient { return AvroTypeFactory.getProduct(this.proxy.getProductById(productId)); } catch (AvroRemoteException e) { throw new CatalogException(e.getMessage()); + } finally { + try { + this.client.close(); + } catch (IOException e) { + throw new CatalogException(e.getMessage()); + } } } @@ -582,6 +828,12 @@ public class AvroFileManagerClient implements FileManagerClient { return AvroTypeFactory.getProduct(this.proxy.getProductByName(productName)); } catch (AvroRemoteException e) { throw new CatalogException(e.getMessage()); + } finally { + try { + this.client.close(); + } catch (IOException e) { + throw new CatalogException(e.getMessage()); + } } } @@ -696,30 +948,60 @@ public class AvroFileManagerClient implements FileManagerClient { } throw new Exception("Failed to ingest product [" + product + "] : " + e.getMessage()); + } finally { + try { + this.client.close(); + } catch (IOException e) { + throw new FileManagerException(e.getMessage()); + } } } @Override public Metadata getCatalogValues(Metadata metadata, ProductType productType) throws Exception { - return AvroTypeFactory.getMetadata(this.proxy.getCatalogValues( + try { + return AvroTypeFactory.getMetadata(this.proxy.getCatalogValues( AvroTypeFactory.getAvroMetadata(metadata), AvroTypeFactory.getAvroProductType(productType))); + } finally { + try { + this.client.close(); + } catch (IOException e) { + throw new FileManagerException(e.getMessage()); + } + } } @Override public Metadata getOrigValues(Metadata metadata, ProductType productType) throws Exception { - return AvroTypeFactory.getMetadata(this.proxy.getOrigValues( + try { + return AvroTypeFactory.getMetadata(this.proxy.getOrigValues( AvroTypeFactory.getAvroMetadata(metadata), AvroTypeFactory.getAvroProductType(productType))); + } finally { + try { + this.client.close(); + } catch (IOException e) { + throw new FileManagerException(e.getMessage()); + } + } } @Override public Query getCatalogQuery(Query query, ProductType productType) throws Exception { - return AvroTypeFactory.getQuery(this.proxy.getCatalogQuery( + try { + return AvroTypeFactory.getQuery(this.proxy.getCatalogQuery( AvroTypeFactory.getAvroQuery(query), AvroTypeFactory.getAvroProductType(productType) - )); + )); + } finally { + try { + this.client.close(); + } catch (IOException e) { + throw new FileManagerException(e.getMessage()); + } + } } @Override