|
From: Bryan T. <tho...@us...> - 2007-04-23 18:58:42
|
Update of /cvsroot/cweb/bigdata/src/java/com/bigdata/service In directory sc8-pr-cvs4.sourceforge.net:/tmp/cvs-serv2382/src/java/com/bigdata/service Modified Files: MetadataService.java DataService.java MetadataServer.java Log Message: Refactored the MetadataIndex to extend UnisolatedBTree and put it to some use in the MetadataService and validated aspects of its use in the test case for the metadata service. Index: DataService.java =================================================================== RCS file: /cvsroot/cweb/bigdata/src/java/com/bigdata/service/DataService.java,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** DataService.java 23 Apr 2007 17:22:14 -0000 1.11 --- DataService.java 23 Apr 2007 18:58:38 -0000 1.12 *************** *** 105,108 **** --- 105,115 ---- * an NIO interface to the data service. * + * @todo should the data service monitor key ranges so that it can readily + * reject requests when the index is registered but the key lies outside + * of the range of an index partition mapped onto the data service? This + * probably needs to happen in order for the data service to be able to + * redirect clients if it sheds an index partition while the client has a + * lease. + * * @todo make sure that all service methods that create a {@link Future} do a * get() so that the will block until the serialized task actually runs. Index: MetadataService.java =================================================================== RCS file: /cvsroot/cweb/bigdata/src/java/com/bigdata/service/MetadataService.java,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** MetadataService.java 23 Apr 2007 17:22:14 -0000 1.6 --- MetadataService.java 23 Apr 2007 18:58:38 -0000 1.7 *************** *** 55,60 **** import net.jini.core.lookup.ServiceID; - import com.bigdata.btree.BTree; - import com.bigdata.journal.Journal; import com.bigdata.scaleup.MasterJournal; import com.bigdata.scaleup.MetadataIndex; --- 55,58 ---- *************** *** 67,70 **** --- 65,75 ---- * @version $Id$ * + * @todo Support creation and management of scale-out indices, including mapping + * their index partitions to data services. Build out this functionality + * with a series of test cases that invoke the basic operations + * (registerIndex (done), getPartition (done), putPartition, + * getPartitions, movePartition, etc.) and handle the load-balancing + * later. + * * @todo Provide a means to reconstruct the metadata index from the journal and * index segment data files. We tag each journal and index segment with a *************** *** 84,88 **** * be able to access the historical state of the metadata index that * corresponds to the commit time of interest for the database.) ! * * @todo support two-tier metadata index and reconcile with * {@link MetadataIndex} and {@link MasterJournal}. --- 89,93 ---- * be able to access the historical state of the metadata index that * corresponds to the commit time of interest for the database.) ! * * @todo support two-tier metadata index and reconcile with * {@link MetadataIndex} and {@link MasterJournal}. *************** *** 97,123 **** } - /* - * @todo Support creation and management of scale-out indices, including - * mapping their index partitions to data services. Build out this - * functionality with a series of test cases that invoke the basic - * operations (registerIndex, getPartition, getPartitions, movePartition, - * etc.) and handle the load-balancing later. - */ - /** ! * @todo if if exits already? * * @todo index metadata options (unicode support, per-partition counters, ! * etc.) i had been passing in the BTree instance, but that does ! * not work as well in a distributed environment. ! * ! * @todo refactor so that the {@link MetadataIndex} can be used with a ! * normal {@link Journal} ! * ! * @todo create the initial partition and assign to the "least used" data ! * service (the data service impl needs to aggregate events and log ! * them in a manner that gets noticed by the metadata service). */ ! public UUID registerIndex(String name) throws IOException, InterruptedException, ExecutionException { MetadataIndex mdi = (MetadataIndex) journal.serialize( --- 102,114 ---- } /** ! * @todo if if exits already? (and has consistent/inconsistent metadata)? * * @todo index metadata options (unicode support, per-partition counters, ! * etc.) i had been passing in the BTree instance, but that does not ! * work as well in a distributed environment. */ ! public UUID registerIndex(String name) throws IOException, ! InterruptedException, ExecutionException { MetadataIndex mdi = (MetadataIndex) journal.serialize( *************** *** 187,195 **** final UUID managedIndexUUID = UUID.randomUUID(); ! MetadataIndex mdi = new MetadataIndex(journal, ! BTree.DEFAULT_BRANCHING_FACTOR, metadataIndexUUID, managedIndexUUID, name); /* * Setup the initial partition which is able to accept any key. */ --- 178,190 ---- final UUID managedIndexUUID = UUID.randomUUID(); ! MetadataIndex mdi = new MetadataIndex(journal, metadataIndexUUID, managedIndexUUID, name); /* + * Register the metadata index. + */ + journal.registerIndex(metadataName, mdi); + + /* * Setup the initial partition which is able to accept any key. */ *************** *** 197,206 **** ServiceID dataServiceID = getUnderUtilizedDataService(); - UUID dataServiceUUID = new UUID(dataServiceID - .getMostSignificantBits(), dataServiceID - .getLeastSignificantBits()); - final UUID[] dataServices = new UUID[]{ ! dataServiceUUID }; --- 192,199 ---- ServiceID dataServiceID = getUnderUtilizedDataService(); final UUID[] dataServices = new UUID[]{ ! ! MetadataServer.serviceID2UUID(dataServiceID) ! }; *************** *** 219,223 **** * MUST NOT be run inside of the serialized write on the metadata * index itself. It is a good question exactly when this operation ! * should be run.... */ --- 212,218 ---- * MUST NOT be run inside of the serialized write on the metadata * index itself. It is a good question exactly when this operation ! * should be run.... One option would be lazily by the data service ! * when it receives a request for an index / index key range that ! * was not known to be mapped to that data service. */ Index: MetadataServer.java =================================================================== RCS file: /cvsroot/cweb/bigdata/src/java/com/bigdata/service/MetadataServer.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** MetadataServer.java 23 Apr 2007 17:22:14 -0000 1.4 --- MetadataServer.java 23 Apr 2007 18:58:38 -0000 1.5 *************** *** 53,56 **** --- 53,57 ---- import java.util.Map; import java.util.Properties; + import java.util.UUID; import java.util.concurrent.ConcurrentHashMap; *************** *** 104,107 **** --- 105,140 ---- /** + * Convert a Jini {@link ServiceID} to a {@link UUID} (this changes the kind + * of UUID implementation object but preserves the UUID data). + * + * @param serviceID + * The {@link ServiceID}. + * + * @return The {@link UUID}. + */ + public static UUID serviceID2UUID(ServiceID serviceID) { + + return new UUID(serviceID.getMostSignificantBits(), serviceID + .getLeastSignificantBits()); + + } + + /** + * Convert a {@link UUID} to a Jini {@link ServiceID} (this changes the kind + * of UUID implementation object but preserves the UUID data). + * + * @param uuid + * The {@link UUID}. + * + * @return The Jini {@link ServiceID}. + */ + public static ServiceID uuid2ServiceID(UUID uuid) { + + return new ServiceID(uuid.getMostSignificantBits(), uuid + .getLeastSignificantBits()); + + } + + /** * @param args */ |