Changeset 5269
Legend:
- Unmodified
- Added
- Removed
-
trunk/cr/process/client/src/main/java/org/lilyproject/client/LilyClient.java
r5184 r5269 37 37 import org.lilyproject.repository.avro.AvroConverter; 38 38 import org.lilyproject.repository.impl.*; 39 import org.lilyproject.util.hbase.HBaseAdminFactory; 39 40 import org.lilyproject.util.hbase.HBaseTableFactory; 40 41 import org.lilyproject.util.hbase.HBaseTableFactoryImpl; … … 156 157 RemoteTypeManager typeManager = new RemoteTypeManager(parseAddressAndPort(server.lilyAddressAndPort), 157 158 remoteConverter, idGenerator, zk, schemaCache); 158 159 160 // TODO BlobManager can probably be shared across all repositories 159 161 BlobManager blobManager = getBlobManager(zk); 160 162 … … 169 171 public static BlobManager getBlobManager(ZooKeeperItf zk) throws IOException { 170 172 Configuration configuration = getBlobHBaseConfiguration(zk); 173 // Avoid HBase(Admin)/ZooKeeper connection leaks when using new Configuration objects each time. 174 configuration = HBaseAdminFactory.getExisting(configuration); 171 175 HBaseTableFactory hbaseTableFactory = new HBaseTableFactoryImpl(configuration); 172 176 173 177 URI dfsUri = getDfsUri(zk); 174 178 FileSystem fs = FileSystem.get(DfsUri.getBaseDfsUri(dfsUri), configuration); -
trunk/global/hbase-util/src/main/java/org/lilyproject/util/hbase/HBaseAdminFactory.java
r5121 r5269 10 10 11 11 import java.util.HashMap; 12 import java.util.Iterator; 12 13 import java.util.Map; 13 14 … … 44 45 admins.clear(); 45 46 } 47 48 /** 49 * If there is an existing configuration which has all the same properties as this configuration, return it. 50 * Otherwise, returns the passed conf. This is an expensive method. 51 */ 52 public static Configuration getExisting(Configuration conf) { 53 Configuration[] confs; 54 synchronized (HBaseAdminFactory.class) { 55 confs = admins.keySet().toArray(new Configuration[0]); 56 } 57 58 Map<String, String> confAsMap = toMap(conf); 59 60 for (Configuration current : confs) { 61 if (toMap(current).equals(confAsMap)) { 62 return current; 63 } 64 } 65 66 return conf; 67 } 68 69 private static Map<String, String> toMap(Configuration conf) { 70 Map<String, String> result = new HashMap<String, String>(); 71 Iterator<Map.Entry<String, String>> it = conf.iterator(); 72 while (it.hasNext()) { 73 Map.Entry<String, String> entry = it.next(); 74 result.put(entry.getKey(), entry.getValue()); 75 } 76 return result; 77 } 46 78 }
Note: See TracChangeset
for help on using the changeset viewer.