當前位置: 首頁>>代碼示例>>Java>>正文


Java Environment.openSecondaryDatabase方法代碼示例

本文整理匯總了Java中com.sleepycat.je.Environment.openSecondaryDatabase方法的典型用法代碼示例。如果您正苦於以下問題:Java Environment.openSecondaryDatabase方法的具體用法?Java Environment.openSecondaryDatabase怎麽用?Java Environment.openSecondaryDatabase使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在com.sleepycat.je.Environment的用法示例。


在下文中一共展示了Environment.openSecondaryDatabase方法的13個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: open

import com.sleepycat.je.Environment; //導入方法依賴的package包/類
private void open()
    throws DatabaseException {

    EnvironmentConfig envConfig = TestUtils.initEnvConfig();
    envConfig.setAllowCreate(true);

    env = new Environment(envHome, envConfig);

    DatabaseConfig priConfig = new DatabaseConfig();
    priConfig.setAllowCreate(true);

    priDb = env.openDatabase(null, "pri", priConfig);

    SecondaryConfig secConfig = new SecondaryConfig();
    secConfig.setAllowCreate(true);
    secConfig.setSortedDuplicates(true);
    secConfig.setKeyCreator(new KeyCreator());

    secDb = env.openSecondaryDatabase(null, "sec", priDb, secConfig);
}
 
開發者ID:nologic,項目名稱:nabs,代碼行數:21,代碼來源:SecondarySplitTestMain.java

示例2: openSecondaryDatabase

import com.sleepycat.je.Environment; //導入方法依賴的package包/類
public static SecondaryDatabase
              openSecondaryDatabase(Environment env,
                                    Transaction txn,
                                    String file,
                                    String name,
                                    Database primary,
                                    SecondaryConfig config)
    throws DatabaseException, FileNotFoundException {

    return env.openSecondaryDatabase(txn, makeDbName(file, name),
                                     primary, config);
}
 
開發者ID:nologic,項目名稱:nabs,代碼行數:13,代碼來源:DbCompat.java

示例3: setup

import com.sleepycat.je.Environment; //導入方法依賴的package包/類
public void setup(File envHome, boolean readOnly)
    throws DatabaseException {

    EnvironmentConfig myEnvConfig = new EnvironmentConfig();
    DatabaseConfig myDbConfig = new DatabaseConfig();
    SecondaryConfig mySecConfig = new SecondaryConfig();

    // If the environment is read-only, then
    // make the databases read-only too.
    myEnvConfig.setReadOnly(readOnly);
    myDbConfig.setReadOnly(readOnly);
    mySecConfig.setReadOnly(readOnly);

    // If the environment is opened for write, then we want to be
    // able to create the environment and databases if
    // they do not exist.
    myEnvConfig.setAllowCreate(!readOnly);
    myDbConfig.setAllowCreate(!readOnly);
    mySecConfig.setAllowCreate(!readOnly);

    // Allow transactions if we are writing to the database
    myEnvConfig.setTransactional(!readOnly);
    myDbConfig.setTransactional(!readOnly);
    mySecConfig.setTransactional(!readOnly);

    // Open the environment
    myEnv = new Environment(envHome, myEnvConfig);

    // Now open, or create and open, our databases
    // Open the vendors and inventory databases
    vendorDb = myEnv.openDatabase(null,
                                  "VendorDB",
                                   myDbConfig);

    inventoryDb = myEnv.openDatabase(null,
                                    "InventoryDB",
                                     myDbConfig);

    // Open the class catalog db. This is used to
    // optimize class serialization.
    classCatalogDb =
        myEnv.openDatabase(null,
                           "ClassCatalogDB",
                           myDbConfig);

    // Create our class catalog
    classCatalog = new StoredClassCatalog(classCatalogDb);

    // Need a tuple binding for the Inventory class.
    // We use the InventoryBinding class
    // that we implemented for this purpose.
    TupleBinding inventoryBinding = new InventoryBinding();

    // Open the secondary database. We use this to create a
    // secondary index for the inventory database

    // We want to maintain an index for the inventory entries based
    // on the item name. So, instantiate the appropriate key creator
    // and open a secondary database.
    ItemNameKeyCreator keyCreator =
        new ItemNameKeyCreator(inventoryBinding);

    // Set up additional secondary properties
    // Need to allow duplicates for our secondary database
    mySecConfig.setSortedDuplicates(true);
    mySecConfig.setAllowPopulate(true); // Allow autopopulate
    mySecConfig.setKeyCreator(keyCreator);

    // Now open it
    itemNameIndexDb =
        myEnv.openSecondaryDatabase(
                null,
                "itemNameIndex", // index name
                inventoryDb,     // the primary db that we're indexing
                mySecConfig);    // the secondary config
}
 
開發者ID:prat0318,項目名稱:dbms,代碼行數:77,代碼來源:MyDbEnv.java

示例4: SampleDatabase

import com.sleepycat.je.Environment; //導入方法依賴的package包/類
/**
 * Open all storage containers, indices, and catalogs.
 */
public SampleDatabase(String homeDirectory)
    throws DatabaseException {

    // Open the Berkeley DB environment in transactional mode.
    //
    System.out.println("Opening environment in: " + homeDirectory);
    EnvironmentConfig envConfig = new EnvironmentConfig();
    envConfig.setTransactional(true);
    envConfig.setAllowCreate(true);
    env = new Environment(new File(homeDirectory), envConfig);

    // Set the Berkeley DB config for opening all stores.
    //
    DatabaseConfig dbConfig = new DatabaseConfig();
    dbConfig.setTransactional(true);
    dbConfig.setAllowCreate(true);

    // Create the Serial class catalog.  This holds the serialized class
    // format for all database records of serial format.
    //
    Database catalogDb = env.openDatabase(null, CLASS_CATALOG, dbConfig);
    javaCatalog = new StoredClassCatalog(catalogDb);

    // Use the TupleSerialDbFactory for a Serial/Tuple-based database
    // where marshalling interfaces are used.
    //
    factory = new TupleSerialFactory(javaCatalog);

    // Open the Berkeley DB database for the part, supplier and shipment
    // stores.  The stores are opened with no duplicate keys allowed.
    //
    partDb = env.openDatabase(null, PART_STORE, dbConfig);

    supplierDb = env.openDatabase(null, SUPPLIER_STORE, dbConfig);

    shipmentDb = env.openDatabase(null, SHIPMENT_STORE, dbConfig);

    // Open the SecondaryDatabase for the city index of the supplier store,
    // and for the part and supplier indices of the shipment store.
    // Duplicate keys are allowed since more than one supplier may be in
    // the same city, and more than one shipment may exist for the same
    // supplier or part.  A foreign key constraint is defined for the
    // supplier and part indices to ensure that a shipment only refers to
    // existing part and supplier keys.  The CASCADE delete action means
    // that shipments will be deleted if their associated part or supplier
    // is deleted.
    //
    SecondaryConfig secConfig = new SecondaryConfig();
    secConfig.setTransactional(true);
    secConfig.setAllowCreate(true);
    secConfig.setSortedDuplicates(true);

    secConfig.setKeyCreator(factory.getKeyCreator(Supplier.class,
                                                  Supplier.CITY_KEY));
    supplierByCityDb = env.openSecondaryDatabase(null, SUPPLIER_CITY_INDEX,
                                                 supplierDb, secConfig);

    secConfig.setForeignKeyDatabase(partDb);
    secConfig.setForeignKeyDeleteAction(ForeignKeyDeleteAction.CASCADE);
    secConfig.setKeyCreator(factory.getKeyCreator(Shipment.class,
                                                  Shipment.PART_KEY));
    shipmentByPartDb = env.openSecondaryDatabase(null, SHIPMENT_PART_INDEX,
                                                 shipmentDb, secConfig);

    secConfig.setForeignKeyDatabase(supplierDb);
    secConfig.setForeignKeyDeleteAction(ForeignKeyDeleteAction.CASCADE);
    secConfig.setKeyCreator(factory.getKeyCreator(Shipment.class,
                                                  Shipment.SUPPLIER_KEY));
    shipmentBySupplierDb = env.openSecondaryDatabase(null,
                                                 SHIPMENT_SUPPLIER_INDEX,
                                                 shipmentDb, secConfig);
}
 
開發者ID:prat0318,項目名稱:dbms,代碼行數:76,代碼來源:SampleDatabase.java

示例5: SampleDatabase

import com.sleepycat.je.Environment; //導入方法依賴的package包/類
/**
 * Open all storage containers, indices, and catalogs.
 */
public SampleDatabase(String homeDirectory)
    throws DatabaseException, FileNotFoundException {

    // Open the Berkeley DB environment in transactional mode.
    //
    System.out.println("Opening environment in: " + homeDirectory);
    EnvironmentConfig envConfig = new EnvironmentConfig();
    envConfig.setTransactional(true);
    envConfig.setAllowCreate(true);
    env = new Environment(new File(homeDirectory), envConfig);

    // Set the Berkeley DB config for opening all stores.
    //
    DatabaseConfig dbConfig = new DatabaseConfig();
    dbConfig.setTransactional(true);
    dbConfig.setAllowCreate(true);

    // Create the Serial class catalog.  This holds the serialized class
    // format for all database records of serial format.
    //
    Database catalogDb = env.openDatabase(null, CLASS_CATALOG, dbConfig);
    javaCatalog = new StoredClassCatalog(catalogDb);

    // Open the Berkeley DB database for the part, supplier and shipment
    // stores.  The stores are opened with no duplicate keys allowed.
    //
    partDb = env.openDatabase(null, PART_STORE, dbConfig);

    supplierDb = env.openDatabase(null, SUPPLIER_STORE, dbConfig);

    shipmentDb = env.openDatabase(null, SHIPMENT_STORE, dbConfig);
    
    // Open the SecondaryDatabase for the city index of the supplier store,
    // and for the part and supplier indices of the shipment store.
    // Duplicate keys are allowed since more than one supplier may be in
    // the same city, and more than one shipment may exist for the same
    // supplier or part.  A foreign key constraint is defined for the
    // supplier and part indices to ensure that a shipment only refers to
    // existing part and supplier keys.  The CASCADE delete action means
    // that shipments will be deleted if their associated part or supplier
    // is deleted.
    //
    SecondaryConfig secConfig = new SecondaryConfig();
    secConfig.setTransactional(true);
    secConfig.setAllowCreate(true);
    secConfig.setSortedDuplicates(true);

    secConfig.setKeyCreator(new SupplierByCityKeyCreator(javaCatalog,
                                                 SupplierData.class));
    supplierByCityDb = env.openSecondaryDatabase(null, SUPPLIER_CITY_INDEX,
                                                 supplierDb, secConfig);

    secConfig.setForeignKeyDatabase(partDb);
    secConfig.setForeignKeyDeleteAction(ForeignKeyDeleteAction.CASCADE);
    secConfig.setKeyCreator(new ShipmentByPartKeyCreator(javaCatalog,
                                                 ShipmentData.class));
    shipmentByPartDb = env.openSecondaryDatabase(null, SHIPMENT_PART_INDEX,
                                                 shipmentDb, secConfig);

    secConfig.setForeignKeyDatabase(supplierDb);
    secConfig.setForeignKeyDeleteAction(ForeignKeyDeleteAction.CASCADE);
    secConfig.setKeyCreator(new ShipmentBySupplierKeyCreator(javaCatalog,
                                                 ShipmentData.class));
    shipmentBySupplierDb = env.openSecondaryDatabase(null,
                                                 SHIPMENT_SUPPLIER_INDEX,
                                                 shipmentDb, secConfig);
}
 
開發者ID:nologic,項目名稱:nabs,代碼行數:71,代碼來源:SampleDatabase.java

示例6: SampleDatabase

import com.sleepycat.je.Environment; //導入方法依賴的package包/類
/**
 * Open all storage containers, indices, and catalogs.
 */
public SampleDatabase(String homeDirectory)
    throws DatabaseException, FileNotFoundException {

    // Open the Berkeley DB environment in transactional mode.
    //
    System.out.println("Opening environment in: " + homeDirectory);
    EnvironmentConfig envConfig = new EnvironmentConfig();
    envConfig.setTransactional(true);
    envConfig.setAllowCreate(true);
    env = new Environment(new File(homeDirectory), envConfig);

    // Set the Berkeley DB config for opening all stores.
    //
    DatabaseConfig dbConfig = new DatabaseConfig();
    dbConfig.setTransactional(true);
    dbConfig.setAllowCreate(true);

    // Create the Serial class catalog.  This holds the serialized class
    // format for all database records of serial format.
    //
    Database catalogDb = env.openDatabase(null, CLASS_CATALOG, dbConfig);
    javaCatalog = new StoredClassCatalog(catalogDb);

    // Use the TupleSerialDbFactory for a Serial/Tuple-based database
    // where marshalling interfaces are used.
    //
    factory = new TupleSerialFactory(javaCatalog);

    // Open the Berkeley DB database for the part, supplier and shipment
    // stores.  The stores are opened with no duplicate keys allowed.
    //
    partDb = env.openDatabase(null, PART_STORE, dbConfig);

    supplierDb = env.openDatabase(null, SUPPLIER_STORE, dbConfig);

    shipmentDb = env.openDatabase(null, SHIPMENT_STORE, dbConfig);

    // Open the SecondaryDatabase for the city index of the supplier store,
    // and for the part and supplier indices of the shipment store.
    // Duplicate keys are allowed since more than one supplier may be in
    // the same city, and more than one shipment may exist for the same
    // supplier or part.  A foreign key constraint is defined for the
    // supplier and part indices to ensure that a shipment only refers to
    // existing part and supplier keys.  The CASCADE delete action means
    // that shipments will be deleted if their associated part or supplier
    // is deleted.
    //
    SecondaryConfig secConfig = new SecondaryConfig();
    secConfig.setTransactional(true);
    secConfig.setAllowCreate(true);
    secConfig.setSortedDuplicates(true);

    secConfig.setKeyCreator(factory.getKeyCreator(Supplier.class,
                                                  Supplier.CITY_KEY));
    supplierByCityDb = env.openSecondaryDatabase(null, SUPPLIER_CITY_INDEX,
                                                 supplierDb, secConfig);

    secConfig.setForeignKeyDatabase(partDb);
    secConfig.setForeignKeyDeleteAction(ForeignKeyDeleteAction.CASCADE);
    secConfig.setKeyCreator(factory.getKeyCreator(Shipment.class,
                                                  Shipment.PART_KEY));
    shipmentByPartDb = env.openSecondaryDatabase(null, SHIPMENT_PART_INDEX,
                                                 shipmentDb, secConfig);

    secConfig.setForeignKeyDatabase(supplierDb);
    secConfig.setForeignKeyDeleteAction(ForeignKeyDeleteAction.CASCADE);
    secConfig.setKeyCreator(factory.getKeyCreator(Shipment.class,
                                                  Shipment.SUPPLIER_KEY));
    shipmentBySupplierDb = env.openSecondaryDatabase(null,
                                                 SHIPMENT_SUPPLIER_INDEX,
                                                 shipmentDb, secConfig);
}
 
開發者ID:nologic,項目名稱:nabs,代碼行數:76,代碼來源:SampleDatabase.java

示例7: SampleDatabase

import com.sleepycat.je.Environment; //導入方法依賴的package包/類
/**
 * Open all storage containers, indices, and catalogs.
 */
public SampleDatabase(String homeDirectory)
    throws DatabaseException, FileNotFoundException {

    // Open the Berkeley DB environment in transactional mode.
    //
    System.out.println("Opening environment in: " + homeDirectory);
    EnvironmentConfig envConfig = new EnvironmentConfig();
    envConfig.setTransactional(true);
    envConfig.setAllowCreate(true);
    env = new Environment(new File(homeDirectory), envConfig);

    // Set the Berkeley DB config for opening all stores.
    //
    DatabaseConfig dbConfig = new DatabaseConfig();
    dbConfig.setTransactional(true);
    dbConfig.setAllowCreate(true);

    // Create the Serial class catalog.  This holds the serialized class
    // format for all database records of serial format.
    //
    Database catalogDb = env.openDatabase(null, CLASS_CATALOG, dbConfig);
    javaCatalog = new StoredClassCatalog(catalogDb);

    // Open the Berkeley DB database for the part, supplier and shipment
    // stores.  The stores are opened with no duplicate keys allowed.
    //
    partDb = env.openDatabase(null, PART_STORE, dbConfig);

    supplierDb = env.openDatabase(null, SUPPLIER_STORE, dbConfig);

    shipmentDb = env.openDatabase(null, SHIPMENT_STORE, dbConfig);
    
    // Open the SecondaryDatabase for the city index of the supplier store,
    // and for the part and supplier indices of the shipment store.
    // Duplicate keys are allowed since more than one supplier may be in
    // the same city, and more than one shipment may exist for the same
    // supplier or part.  A foreign key constraint is defined for the
    // supplier and part indices to ensure that a shipment only refers to
    // existing part and supplier keys.  The CASCADE delete action means
    // that shipments will be deleted if their associated part or supplier
    // is deleted.
    //
    SecondaryConfig secConfig = new SecondaryConfig();
    secConfig.setTransactional(true);
    secConfig.setAllowCreate(true);
    secConfig.setSortedDuplicates(true);

    secConfig.setKeyCreator(
        new SupplierByCityKeyCreator(javaCatalog,
                                     SupplierKey.class,
                                     SupplierData.class,
                                     String.class));
    supplierByCityDb = env.openSecondaryDatabase(null, SUPPLIER_CITY_INDEX,
                                                 supplierDb, secConfig);

    secConfig.setForeignKeyDatabase(partDb);
    secConfig.setForeignKeyDeleteAction(ForeignKeyDeleteAction.CASCADE);
    secConfig.setKeyCreator(
        new ShipmentByPartKeyCreator(javaCatalog,
                                     ShipmentKey.class,
                                     ShipmentData.class,
                                     PartKey.class));
    shipmentByPartDb = env.openSecondaryDatabase(null, SHIPMENT_PART_INDEX,
                                                 shipmentDb, secConfig);

    secConfig.setForeignKeyDatabase(supplierDb);
    secConfig.setForeignKeyDeleteAction(ForeignKeyDeleteAction.CASCADE);
    secConfig.setKeyCreator(
        new ShipmentBySupplierKeyCreator(javaCatalog,
                                         ShipmentKey.class,
                                         ShipmentData.class,
                                         SupplierKey.class));
    shipmentBySupplierDb = env.openSecondaryDatabase(null,
                                                 SHIPMENT_SUPPLIER_INDEX,
                                                 shipmentDb, secConfig);
}
 
開發者ID:nologic,項目名稱:nabs,代碼行數:80,代碼來源:SampleDatabase.java

示例8: SampleDatabase

import com.sleepycat.je.Environment; //導入方法依賴的package包/類
/**
 * Open all storage containers, indices, and catalogs.
 */
public SampleDatabase(String homeDirectory)
    throws DatabaseException, FileNotFoundException {

    // Open the Berkeley DB environment in transactional mode.
    //
    System.out.println("Opening environment in: " + homeDirectory);
    EnvironmentConfig envConfig = new EnvironmentConfig();
    envConfig.setTransactional(true);
    envConfig.setAllowCreate(true);
    env = new Environment(new File(homeDirectory), envConfig);

    // Set the Berkeley DB config for opening all stores.
    //
    DatabaseConfig dbConfig = new DatabaseConfig();
    dbConfig.setTransactional(true);
    dbConfig.setAllowCreate(true);

    // Create the Serial class catalog.  This holds the serialized class
    // format for all database records of serial format.
    //
    Database catalogDb = env.openDatabase(null, CLASS_CATALOG, dbConfig);
    javaCatalog = new StoredClassCatalog(catalogDb);

    // Open the Berkeley DB database for the part, supplier and shipment
    // stores.  The stores are opened with no duplicate keys allowed.
    //
    partDb = env.openDatabase(null, PART_STORE, dbConfig);

    supplierDb = env.openDatabase(null, SUPPLIER_STORE, dbConfig);

    shipmentDb = env.openDatabase(null, SHIPMENT_STORE, dbConfig);
    
    // Open the SecondaryDatabase for the city index of the supplier store,
    // and for the part and supplier indices of the shipment store.
    // Duplicate keys are allowed since more than one supplier may be in
    // the same city, and more than one shipment may exist for the same
    // supplier or part.  A foreign key constraint is defined for the
    // supplier and part indices to ensure that a shipment only refers to
    // existing part and supplier keys.  The CASCADE delete action means
    // that shipments will be deleted if their associated part or supplier
    // is deleted.
    //
    SecondaryConfig secConfig = new SecondaryConfig();
    secConfig.setTransactional(true);
    secConfig.setAllowCreate(true);
    secConfig.setSortedDuplicates(true);

    secConfig.setKeyCreator(new MarshalledKeyCreator(javaCatalog,
                                                     Supplier.class,
                                                     Supplier.CITY_KEY));
    supplierByCityDb = env.openSecondaryDatabase(null, SUPPLIER_CITY_INDEX,
                                                 supplierDb, secConfig);

    secConfig.setForeignKeyDatabase(partDb);
    secConfig.setForeignKeyDeleteAction(ForeignKeyDeleteAction.CASCADE);
    secConfig.setKeyCreator(new MarshalledKeyCreator(javaCatalog,
                                                     Shipment.class,
                                                     Shipment.PART_KEY));
    shipmentByPartDb = env.openSecondaryDatabase(null, SHIPMENT_PART_INDEX,
                                                 shipmentDb, secConfig);

    secConfig.setForeignKeyDatabase(supplierDb);
    secConfig.setForeignKeyDeleteAction(ForeignKeyDeleteAction.CASCADE);
    secConfig.setKeyCreator(new MarshalledKeyCreator(javaCatalog,
                                                     Shipment.class,
                                                 Shipment.SUPPLIER_KEY));
    shipmentBySupplierDb = env.openSecondaryDatabase(null,
                                                 SHIPMENT_SUPPLIER_INDEX,
                                                 shipmentDb, secConfig);
}
 
開發者ID:nologic,項目名稱:nabs,代碼行數:74,代碼來源:SampleDatabase.java

示例9: SampleDatabase

import com.sleepycat.je.Environment; //導入方法依賴的package包/類
/**
 * Open all storage containers, indices, and catalogs.
 */
public SampleDatabase(String homeDirectory)
    throws DatabaseException, FileNotFoundException {

    // Open the Berkeley DB environment in transactional mode.
    //
    System.out.println("Opening environment in: " + homeDirectory);
    EnvironmentConfig envConfig = new EnvironmentConfig();
    envConfig.setTransactional(true);
    envConfig.setAllowCreate(true);
    env = new Environment(new File(homeDirectory), envConfig);

    // Set the Berkeley DB config for opening all stores.
    //
    DatabaseConfig dbConfig = new DatabaseConfig();
    dbConfig.setTransactional(true);
    dbConfig.setAllowCreate(true);

    // Create the Serial class catalog.  This holds the serialized class
    // format for all database records of serial format.
    //
    Database catalogDb = env.openDatabase(null, CLASS_CATALOG, dbConfig);
    javaCatalog = new StoredClassCatalog(catalogDb);

    // Open the Berkeley DB database for the part, supplier and shipment
    // stores.  The stores are opened with no duplicate keys allowed.
    //
    partDb = env.openDatabase(null, PART_STORE, dbConfig);

    supplierDb = env.openDatabase(null, SUPPLIER_STORE, dbConfig);

    shipmentDb = env.openDatabase(null, SHIPMENT_STORE, dbConfig);
    
    // Open the SecondaryDatabase for the city index of the supplier store,
    // and for the part and supplier indices of the shipment store.
    // Duplicate keys are allowed since more than one supplier may be in
    // the same city, and more than one shipment may exist for the same
    // supplier or part.  A foreign key constraint is defined for the
    // supplier and part indices to ensure that a shipment only refers to
    // existing part and supplier keys.  The CASCADE delete action means
    // that shipments will be deleted if their associated part or supplier
    // is deleted.
    //
    SecondaryConfig secConfig = new SecondaryConfig();
    secConfig.setTransactional(true);
    secConfig.setAllowCreate(true);
    secConfig.setSortedDuplicates(true);

    secConfig.setKeyCreator(new SupplierByCityKeyCreator(javaCatalog,
                                                         Supplier.class));
    supplierByCityDb = env.openSecondaryDatabase(null, SUPPLIER_CITY_INDEX,
                                                 supplierDb, secConfig);

    secConfig.setForeignKeyDatabase(partDb);
    secConfig.setForeignKeyDeleteAction(ForeignKeyDeleteAction.CASCADE);
    secConfig.setKeyCreator(new ShipmentByPartKeyCreator(javaCatalog,
                                                         Shipment.class));
    shipmentByPartDb = env.openSecondaryDatabase(null, SHIPMENT_PART_INDEX,
                                                 shipmentDb, secConfig);

    secConfig.setForeignKeyDatabase(supplierDb);
    secConfig.setForeignKeyDeleteAction(ForeignKeyDeleteAction.CASCADE);
    secConfig.setKeyCreator(new ShipmentBySupplierKeyCreator(javaCatalog,
                                                          Shipment.class));
    shipmentBySupplierDb = env.openSecondaryDatabase(null,
                                                 SHIPMENT_SUPPLIER_INDEX,
                                                 shipmentDb, secConfig);
}
 
開發者ID:nologic,項目名稱:nabs,代碼行數:71,代碼來源:SampleDatabase.java

示例10: setup

import com.sleepycat.je.Environment; //導入方法依賴的package包/類
public void setup(File envHome, boolean readOnly) 
    throws DatabaseException {

    EnvironmentConfig myEnvConfig = new EnvironmentConfig();
    DatabaseConfig myDbConfig = new DatabaseConfig();
    SecondaryConfig mySecConfig = new SecondaryConfig();

    // If the environment is read-only, then
    // make the databases read-only too.
    myEnvConfig.setReadOnly(readOnly);
    myDbConfig.setReadOnly(readOnly);
    mySecConfig.setReadOnly(readOnly);

    // If the environment is opened for write, then we want to be 
    // able to create the environment and databases if 
    // they do not exist.
    myEnvConfig.setAllowCreate(!readOnly);
    myDbConfig.setAllowCreate(!readOnly);
    mySecConfig.setAllowCreate(!readOnly);

    // Allow transactions if we are writing to the database
    myEnvConfig.setTransactional(!readOnly);
    myDbConfig.setTransactional(!readOnly);
    mySecConfig.setTransactional(!readOnly);

    // Open the environment
    myEnv = new Environment(envHome, myEnvConfig);

    // Now open, or create and open, our databases
    // Open the vendors and inventory databases
    vendorDb = myEnv.openDatabase(null, 
                                  "VendorDB",
                                   myDbConfig);

    inventoryDb = myEnv.openDatabase(null, 
                                    "InventoryDB",
                                     myDbConfig);
    
    // Open the class catalog db. This is used to 
    // optimize class serialization.
    classCatalogDb = 
        myEnv.openDatabase(null, 
                           "ClassCatalogDB",
                           myDbConfig);

    // Create our class catalog
    classCatalog = new StoredClassCatalog(classCatalogDb);

    // Need a tuple binding for the Inventory class. 
    // We use the InventoryBinding class
    // that we implemented for this purpose.
    TupleBinding inventoryBinding = new InventoryBinding();
                                                                                                                              
    // Open the secondary database. We use this to create a
    // secondary index for the inventory database

    // We want to maintain an index for the inventory entries based 
    // on the item name. So, instantiate the appropriate key creator 
    // and open a secondary database.
    ItemNameKeyCreator keyCreator = 
        new ItemNameKeyCreator(new InventoryBinding());

   
    // Set up additional secondary properties
    // Need to allow duplicates for our secondary database
    mySecConfig.setSortedDuplicates(true);
    mySecConfig.setAllowPopulate(true); // Allow autopopulate
    mySecConfig.setKeyCreator(keyCreator);

    // Now open it
    itemNameIndexDb = 
        myEnv.openSecondaryDatabase(
                null,     
                "itemNameIndex", // index name
                inventoryDb,     // the primary db that we're indexing
                mySecConfig);    // the secondary config 
}
 
開發者ID:nologic,項目名稱:nabs,代碼行數:78,代碼來源:MyDbEnv.java

示例11: SampleDatabase

import com.sleepycat.je.Environment; //導入方法依賴的package包/類
/**
 * Open all storage containers, indices, and catalogs.
 */
public SampleDatabase(String homeDirectory)
    throws DatabaseException {

    // Open the Berkeley DB environment in transactional mode.
    //
    System.out.println("Opening environment in: " + homeDirectory);
    EnvironmentConfig envConfig = new EnvironmentConfig();
    envConfig.setTransactional(true);
    envConfig.setAllowCreate(true);
    env = new Environment(new File(homeDirectory), envConfig);

    // Set the Berkeley DB config for opening all stores.
    //
    DatabaseConfig dbConfig = new DatabaseConfig();
    dbConfig.setTransactional(true);
    dbConfig.setAllowCreate(true);

    // Create the Serial class catalog.  This holds the serialized class
    // format for all database records of serial format.
    //
    Database catalogDb = env.openDatabase(null, CLASS_CATALOG, dbConfig);
    javaCatalog = new StoredClassCatalog(catalogDb);

    // Open the Berkeley DB database for the part, supplier and shipment
    // stores.  The stores are opened with no duplicate keys allowed.
    //
    partDb = env.openDatabase(null, PART_STORE, dbConfig);

    supplierDb = env.openDatabase(null, SUPPLIER_STORE, dbConfig);

    shipmentDb = env.openDatabase(null, SHIPMENT_STORE, dbConfig);

    // Open the SecondaryDatabase for the city index of the supplier store,
    // and for the part and supplier indices of the shipment store.
    // Duplicate keys are allowed since more than one supplier may be in
    // the same city, and more than one shipment may exist for the same
    // supplier or part.  A foreign key constraint is defined for the
    // supplier and part indices to ensure that a shipment only refers to
    // existing part and supplier keys.  The CASCADE delete action means
    // that shipments will be deleted if their associated part or supplier
    // is deleted.
    //
    SecondaryConfig secConfig = new SecondaryConfig();
    secConfig.setTransactional(true);
    secConfig.setAllowCreate(true);
    secConfig.setSortedDuplicates(true);

    secConfig.setKeyCreator(new MarshalledKeyCreator(javaCatalog,
                                                     Supplier.class,
                                                     Supplier.CITY_KEY));
    supplierByCityDb = env.openSecondaryDatabase(null, SUPPLIER_CITY_INDEX,
                                                 supplierDb, secConfig);

    secConfig.setForeignKeyDatabase(partDb);
    secConfig.setForeignKeyDeleteAction(ForeignKeyDeleteAction.CASCADE);
    secConfig.setKeyCreator(new MarshalledKeyCreator(javaCatalog,
                                                     Shipment.class,
                                                     Shipment.PART_KEY));
    shipmentByPartDb = env.openSecondaryDatabase(null, SHIPMENT_PART_INDEX,
                                                 shipmentDb, secConfig);

    secConfig.setForeignKeyDatabase(supplierDb);
    secConfig.setForeignKeyDeleteAction(ForeignKeyDeleteAction.CASCADE);
    secConfig.setKeyCreator(new MarshalledKeyCreator(javaCatalog,
                                                     Shipment.class,
                                                 Shipment.SUPPLIER_KEY));
    shipmentBySupplierDb = env.openSecondaryDatabase(null,
                                                 SHIPMENT_SUPPLIER_INDEX,
                                                 shipmentDb, secConfig);
}
 
開發者ID:prat0318,項目名稱:dbms,代碼行數:74,代碼來源:SampleDatabase.java

示例12: SorcerDatabase

import com.sleepycat.je.Environment; //導入方法依賴的package包/類
/**
 * Open all storage containers, indices, and catalogs.
 */
public SorcerDatabase(String homeDirectory)
    throws DatabaseException {
    // Open the Berkeley DB environment in transactional mode.
    //System.out.println("Opening environment in: " + homeDirectory);
    EnvironmentConfig envConfig = new EnvironmentConfig();
    envConfig.setLockTimeout(LOCK_TIMEOUT, TimeUnit.MILLISECONDS);
    envConfig.setTransactional(true);
    envConfig.setAllowCreate(true);
    envConfig.setSharedCache(true);
    env = new Environment(new File(homeDirectory), envConfig);

    // Set the Berkeley DB config for opening all stores.
    DatabaseConfig dbConfig = new DatabaseConfig();
    dbConfig.setTransactional(true);
    dbConfig.setAllowCreate(true);

    // Create the Serial class catalog.  This holds the serialized class
    // format for all database records of serial format.
    //
    Database catalogDb = env.openDatabase(null, CLASS_CATALOG, dbConfig);
    javaCatalog = new StoredClassCatalog(catalogDb);

    // Open the Berkeley DB database, the stores are opened
    // with no duplicate keys allowed.

    runtimeDb = env.openDatabase(null, RUNTIME_STORE, dbConfig);

    exertionDb = env.openDatabase(null, EXERTION_STORE, dbConfig);

    contextDb = env.openDatabase(null, CONTEXT_STORE, dbConfig);

    tableDb = env.openDatabase(null, TABLE_STORE, dbConfig);

    varDb = env.openDatabase(null, VAR_STORE, dbConfig);

    varModelDb = env.openDatabase(null, VAR_MODEL_STORE, dbConfig);
    
    uuidObjectDb = env.openDatabase(null, OBJECT_STORE, dbConfig);

    // Open the SecondaryDatabase for the name index of the provider in the runtime store.
    // Duplicate keys are allowed since more than one provider may be in
    // the same exertion.  A foreign key constraint is defined for the
    // name indices to ensure that a runtime only refers to
    // existing provider keys.  The CASCADE delete action means
    // that shipments will be deleted if their associated part or supplier
    // is deleted.
    //
    SecondaryConfig secConfig = new SecondaryConfig();
    secConfig.setTransactional(true);
    secConfig.setAllowCreate(true);
    secConfig.setSortedDuplicates(true);

    secConfig.setKeyCreator(new RuntimeByProviderNameKeyCreator(javaCatalog,
    		ProviderRuntime.class));
    runtimeByProviderNameDb = env.openSecondaryDatabase(null, RUNTIME_PROVIDER_NAME_INDEX,
                                                 runtimeDb, secConfig);
    secConfig.setForeignKeyDatabase(runtimeDb);
    secConfig.setForeignKeyDeleteAction(ForeignKeyDeleteAction.CASCADE);
    secConfig.setKeyCreator(new ExertionByRuntimeKeyCreator(javaCatalog,
                                                         ServiceExertion.class));
}
 
開發者ID:mwsobol,項目名稱:SORCER,代碼行數:65,代碼來源:SorcerDatabase.java

示例13: SampleDatabase

import com.sleepycat.je.Environment; //導入方法依賴的package包/類
/**
 * Open all storage containers, indices, and catalogs.
 */
public SampleDatabase(String homeDirectory)
    throws DatabaseException {

    // Open the Berkeley DB environment in transactional mode.
    //
    System.out.println("Opening environment in: " + homeDirectory);
    EnvironmentConfig envConfig = new EnvironmentConfig();
    envConfig.setTransactional(true);
    envConfig.setAllowCreate(true);
    env = new Environment(new File(homeDirectory), envConfig);

    // Set the Berkeley DB config for opening all stores.
    //
    DatabaseConfig dbConfig = new DatabaseConfig();
    dbConfig.setTransactional(true);
    dbConfig.setAllowCreate(true);

    // Create the Serial class catalog.  This holds the serialized class
    // format for all database records of serial format.
    //
    Database catalogDb = env.openDatabase(null, CLASS_CATALOG, dbConfig);
    javaCatalog = new StoredClassCatalog(catalogDb);

    // Open the Berkeley DB database for the part, supplier and shipment
    // stores.  The stores are opened with no duplicate keys allowed.
    //
    partDb = env.openDatabase(null, PART_STORE, dbConfig);

    supplierDb = env.openDatabase(null, SUPPLIER_STORE, dbConfig);

    shipmentDb = env.openDatabase(null, SHIPMENT_STORE, dbConfig);

    // Open the SecondaryDatabase for the city index of the supplier store,
    // and for the part and supplier indices of the shipment store.
    // Duplicate keys are allowed since more than one supplier may be in
    // the same city, and more than one shipment may exist for the same
    // supplier or part.  A foreign key constraint is defined for the
    // supplier and part indices to ensure that a shipment only refers to
    // existing part and supplier keys.  The CASCADE delete action means
    // that shipments will be deleted if their associated part or supplier
    // is deleted.
    //
    SecondaryConfig secConfig = new SecondaryConfig();
    secConfig.setTransactional(true);
    secConfig.setAllowCreate(true);
    secConfig.setSortedDuplicates(true);

    secConfig.setKeyCreator(new SupplierByCityKeyCreator(javaCatalog,
                                                 SupplierData.class));
    supplierByCityDb = env.openSecondaryDatabase(null, SUPPLIER_CITY_INDEX,
                                                 supplierDb, secConfig);

    secConfig.setForeignKeyDatabase(partDb);
    secConfig.setForeignKeyDeleteAction(ForeignKeyDeleteAction.CASCADE);
    secConfig.setKeyCreator(new ShipmentByPartKeyCreator(javaCatalog,
                                                 ShipmentData.class));
    shipmentByPartDb = env.openSecondaryDatabase(null, SHIPMENT_PART_INDEX,
                                                 shipmentDb, secConfig);

    secConfig.setForeignKeyDatabase(supplierDb);
    secConfig.setForeignKeyDeleteAction(ForeignKeyDeleteAction.CASCADE);
    secConfig.setKeyCreator(new ShipmentBySupplierKeyCreator(javaCatalog,
                                                 ShipmentData.class));
    shipmentBySupplierDb = env.openSecondaryDatabase(null,
                                                 SHIPMENT_SUPPLIER_INDEX,
                                                 shipmentDb, secConfig);
}
 
開發者ID:prat0318,項目名稱:dbms,代碼行數:71,代碼來源:SampleDatabase.java


注:本文中的com.sleepycat.je.Environment.openSecondaryDatabase方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。