Berkeley DB Java Edition (JE) and JRuby Interoperability

I finally got around to doing a quick test of calling Berkeley DB Java Edition (JE) from JRuby (JRuby is a 100% pure-Java implementation of Ruby).
Before we get to JE and JRuby you probably want to know the answer to this question: "Why you would want to run Ruby on a JVM?" The answer is threefold:
1. Ruby Performance. A large amount of effort has been put into tuning contemporary JVMs (e.g. Hotspot, Java 6, etc.) and Ruby programmers (through JRuby) can benefit from these tuning efforts. The JRuby guys have set a goal to make JRuby the fastest Ruby implementation available and Sun is certainly throwing their weight behind that effort.
2. Portability. JRuby is a Ruby interpreter that runs anywhere a Java 5 JVM runs. You download it as a single tar.gz and it will run pretty much anywhere.
3. Legacy Code. JRuby makes legacy Java apps and libraries available to Ruby programmers (did you ever think you'd see the word "legacy" next to the word "Java"?).
JE interoperability with JRuby is important because it means that Ruby programmers now have a simple, embeddable, ACID storage engine (JE) available to them.
To test this interoperability, I cobbled together a simple Ruby test program which does the following:
* Opens an Environment, Database, and Transaction
* Creates 10 records with keys 1..10 and marshaled Ruby Time instances as the corresponding data. This uses the Ruby Marshal package for the data binding and the JE Integer binding on the key side. There's no reason why you couldn't use different marshaling packages or methods for keys and data.
* Commits the transaction,
* Performs a Cursor scan to read those 10 records and prints out the Time instances, and
* Searches for and reads the record with key 5 (an arbitrary key) and prints out the Time instance that is the corresponding data
By the way, hats off to the JRuby developers: all of this code "just worked", out of the box, and most of my two hour investment was spent learning enough basic Ruby to make it all work. If you already know Ruby and JE, then demonstrating this interoperability would take you all of about 10 minutes.
This was all done at the "base API" level of JE and no modifications to JE were required. I used Transactions in my code, but there's no reason that you need to. Mark and I have been talking about how to integrate JE's Direct Persistence Layer (DPL) with JRuby and we think it can be done with some remodularization of some of the DPL code. This is exciting because it would provide POJO ACID persistence to Ruby programmers.
Linda and I have been talking about whether it makes sense to possibly use Ruby as a scripting platform for JE in the future. Given how easy it was to bring up JE and JRuby, this certainly warrants some further thought.
The Ruby code and corresponding output is shown below. By the way, if you see something that I didn't do "The Ruby Way", feel free to let me know.
I'd love to hear about your experiences with JE and JRuby. Feel free to email me a charles.lamb at <theobviousdomain dot com>.
require 'java'
module JESimple
  require 'date'
  # Include all the Java and JE classes that we need.
  include_class 'java.io.File'
  include_class 'com.sleepycat.je.Cursor'
  include_class 'com.sleepycat.je.Database'
  include_class 'com.sleepycat.je.DatabaseConfig'
  include_class 'com.sleepycat.je.DatabaseEntry'
  include_class 'com.sleepycat.je.Environment'
  include_class 'com.sleepycat.je.EnvironmentConfig'
  include_class 'com.sleepycat.je.OperationStatus'
  include_class 'com.sleepycat.je.Transaction'
  include_class 'com.sleepycat.bind.tuple.IntegerBinding'
  include_class 'com.sleepycat.bind.tuple.StringBinding'
  # Create a JE Environment and Database.  Make them transactional.
  envConf = EnvironmentConfig.new()
  envConf.setAllowCreate(true)
  envConf.setTransactional(true)
  f = File.new('/export/home/cwl/work-jruby/JE')
  env = Environment.new(f, envConf);
  dbConf = DatabaseConfig.new()
  dbConf.setAllowCreate(true)
  dbConf.setSortedDuplicates(true)
  dbConf.setTransactional(true)
  db = env.openDatabase(nil, "fooDB", dbConf)
  # Create JE DatabaseEntry's for the key and data.
  key = DatabaseEntry.new()
  data = DatabaseEntry.new()
  # Begin a transaction
  txn = env.beginTransaction(nil, nil)
  # Write some simple marshaled strings to the database.  Use Ruby
  # Time just to demonstrate marshaling a random instance into JE.
  for i in (1..10)
    # For demonstration purposes, use JE's Binding for the key and
    # Ruby's Marshal package for the data.  There's no reason you
    # couldn't use JE's bindings for key and data or visa versa or
    # some other completely different binding.
    IntegerBinding.intToEntry(i, key)
    StringBinding.stringToEntry(Marshal.dump(Time.at(i * 3600 * 24)),
                                data)
    status = db.put(txn, key, data)
    if (status != OperationStatus::SUCCESS)
      puts "Funky status on put #{status}"
    end
  end
  txn.commit()
  # Read back all of the records with a cursor scan.
  puts "Cursor Scan"
  c = db.openCursor(nil, nil)
  while (true) do
    status = c.getNext(key, data, nil)
    if (status != OperationStatus::SUCCESS)
      break
    end
    retKey = IntegerBinding.entryToInt(key)
    retData = Marshal.load(StringBinding.entryToString(data))
    dow =
    puts "#{retKey} => #{retData.strftime('%a %b %d')}"
  end
  c.close()
  # Read back the record with key 5.
  puts "\nSingle Record Retrieval"
  IntegerBinding.intToEntry(5, key)
  status = db.get(nil, key, data, nil)
  if (status != OperationStatus::SUCCESS)
    puts "Funky status on get #{status}"
  end
  retData = Marshal.load(StringBinding.entryToString(data))
  puts "5 => #{retData.strftime('%a %b %d')}"
  db.close
  env.close
end
Cursor Scan
1 => Fri Jan 02
2 => Sat Jan 03
3 => Sun Jan 04
4 => Mon Jan 05
5 => Tue Jan 06
6 => Wed Jan 07
7 => Thu Jan 08
8 => Fri Jan 09
9 => Sat Jan 10
10 => Sun Jan 11
Single Record Retrieval
5 => Tue Jan 06

In my previous post (Berkeley DB Java Edition in JRuby), I showed an example of calling JE's base API layer and mentioned that Mark and I had been thinking about how to use the DPL from JRuby. Our ideal is to be able to define classes in Ruby, annotate those class definitions with DPL-like annotations, and have the JE DPL store them. There are a number of technical hurdles to overcome before we can do this. For instance, Ruby classes defined in JRuby do not map directly to underlying Java classes; instead they all appear as generic RubyObjects to a Java method. Granted, it would be possible for the DPL to fish out all of the fields from these classes using reflection, but presently it's just not set up to do that (hence the modification to the DPL that I spoke about in my previous blog entry). Furthermore, unlike Java, Ruby allows classes to change on the fly (add/remote new fields and methods) causing more heartburn for the DPL unless we required that only frozen Ruby classes could be stored persistently.
On thinking about this some more, we realized that there may be a way to use the DPL from JRuby, albeit with some compromises. The key to this is that in JRuby, if a Java instance is passed back to the "Ruby side" (e.g. through a return value or by calling the constructor for a Java class), it remains a Java instance, even when passed around in JRuby (and eventually passed back into the "Java side"). So what if we require all persistent classes to be defined (i.e. annotated) on the Java side? That buys us the standard DPL annotations (effectively the DDL), freezes the classes that the DPL sees, and still lets us benefit from the POJO persistence of the DPL. All of this can be done without modification to JE or the DPL using the currently available release. I cooked up a quick example that builds on the standard "Person" example in the DPL doc and included the code below.
require 'java'
module DPL
  require 'date'
  # Include all the Java and JE classes that we need.
  include_class 'java.io.File'
  include_class 'com.sleepycat.je.Environment'
  include_class 'com.sleepycat.je.EnvironmentConfig'
  include_class 'com.sleepycat.persist.EntityCursor'
  include_class 'com.sleepycat.persist.EntityIndex'
  include_class 'com.sleepycat.persist.EntityStore'
  include_class 'com.sleepycat.persist.PrimaryIndex'
  include_class 'com.sleepycat.persist.SecondaryIndex'
  include_class 'com.sleepycat.persist.StoreConfig'
  include_class 'com.sleepycat.persist.model.Entity'
  include_class 'com.sleepycat.persist.model.Persistent'
  include_class 'com.sleepycat.persist.model.PrimaryKey'
  include_class 'com.sleepycat.persist.model.SecondaryKey'
  include_class 'com.sleepycat.persist.model.DeleteAction'
  include_class 'persist.Person'
  include_class 'persist.PersonExample'
  # Create a JE Environment and Database.  Make them transactional.
  envConf = EnvironmentConfig.new()
  envConf.setAllowCreate(true)
  envConf.setTransactional(true)
  f = File.new('/export/home/cwl/work-jruby/JE')
  env = Environment.new(f, envConf);
  # Open a transactional entity store.
  storeConfig = StoreConfig.new();
  storeConfig.setAllowCreate(true);
  storeConfig.setTransactional(true);
  store = EntityStore.new(env, "PersonStore", storeConfig);
  class PersonAccessor
    attr_accessor :personBySsn, :personByParentSsn
    def init(store)
      stringClass = java.lang.Class.forName('java.lang.String')
      personClass = java.lang.Class.forName('persist.Person')
      @personBySsn = store.getPrimaryIndex(stringClass, personClass)
      @personByParentSsn =
        store.getSecondaryIndex(@personBySsn, stringClass, "parentSsn");
    end
  end
  dao = PersonAccessor.new(store)
  dao.init(store)
  personBySsn = dao.personBySsn
  person = Person.new('Bob Smith', '111-11-1111', nil)
  personBySsn.put(person);
  person = Person.new('Mary Smith', '333-33-3333', '111-11-1111')
  personBySsn.put(person);
  person = Person.new('Jack Smith', '222-22-2222', '111-11-1111')
  personBySsn.put(person);
  # Get Bob by primary key using the primary index.
  bob = personBySsn.get("111-11-1111")
  puts "Lookup of Bob => #{bob.name}, #{bob.ssn}"
  children = dao.personByParentSsn.subIndex(bob.ssn).entities()
  puts "\nRetrieving children of Bob"
  while (true) do
    child = children.next()
    break if child == nil
    puts "#{child.name}, #{child.ssn}"
  end
  children.close()
  store.close
  env.close
end

Similar Messages

  • Compatibility issues between Berkeley DB Java Edition and Berkeley DB

    We are trying to use both Berkeley DB Java Edition and Berkeley DB (Java/C) in one of our projects. However, they share the common classes (i.e. EntryDingin.java), but with their own different impementation. Is there any reason that they have to share the same names/packages? Can we request to have the shared java classes going into different packages?
    Thanks
    Yao

    Hello Yao,
    You're correct and the DB and JE products were not designed to run under the same classloader in the same JVM. It is very unlikely that we'll be changing the package names, since that would be very disruptive and yet have no value for the overwhelming majority of users. We will note your request, however, for future reference.
    The two workarounds I know of are:
    1. Use a separate classloader for the use of each product.
    2. Use a tool such as jarjar links (http://code.google.com/p/jarjar/) to rename the packages in one or both of the products.
    Option 2 is not something we (the JE team members) have experience with, but it was used successfully by a JE user. The user also pointed out a bug in the jarjar tool to be aware of: http://code.google.com/p/jarjar/issues/detail?id=21
    --mark                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

  • Berkeley DB Java Edition and Java 1.4

    As a Berkeley DB Java Edition user we place a very high value on your input. We need your feedback regarding a product requirement for Java 1.5.
    As time goes on we find ourselves implementing more and more performance enhancements based on facilities found only Java 1.5, primarily in the java.util.concurrent package. When we make these enhancements, we currently also maintain support for Java 1.4 although not at the same level of performance. Maintaining and testing this dual mode operation is beginning to slow down our development process. We would like to move as quickly as possible to take advantage of Java 1.5 performance features, but we are constrained by maintaining support for Java 1.4.
    We are therefore planning to require Java 1.5 in the next major release of Berkeley DB Java Edition. Before finalizing this plan, we need your input on whether Java 1.4 support is important to you. Please let us know what your needs are by replying to this forum message.
    Thanks.
    The Java Edition team

    Morgan,
    Yes, we currently plan to only offer replication for Java 1.5. Our motivations are split between the speed consideration and the codeline issues. We've seen better performance with 1.5. Also taking full advantage of the type safety and concurrent support in 1.5 can end up affecting implementation choices significantly, and can make 1.4 code and 1.5 code diverge a lot.
    As for bug fixing on the 1.4 releases, we don't yet have an official plan. We care very much about supporting our open source users and have been able to provide backwards patches where critical in the past. However, the cost of backporting between 1.5 and 1.4 may be high for some bug fixes, and we'll probably have to decide case by case.
    Regards,
    Linda

  • Berkeley DB Java Edition and Amazon AWS/EC2, EBS

    In a previous OTN thread titled [BerkeleyDB and Amazon EC2/S3|http://forums.oracle.com/forums/thread.jspa?messageID=2627679&tstart=0] questions were raised about using Berkeley DB Java Edition on AWS/EC2. Specifically,
    (1) Does JE work on AWS/EC2, and
    (2) Can S3 be used as a persistent store for JE.
    To follow up on this, recently I have done some work validating JE on AWS and am happy to report that it works fine (there should be no surprise there). I have run it under 32b and 64b Ubuntu distros with Java 6, but I have no reason to think that it doesn't work on other platforms.
    On the second question, I did no work with S3 as a persistent store. Rather, I ran JE with both the Instance Local Storage and with an EBS volume as Environment storage. In the Instance Local Storage case, AWS/EC2 makes no guarantees of durability if the instance fails. In the EBS case, the durability guarantees are much stronger. Both of these storage mechanisms worked fine with JE.
    I call attention to the performance that I observed with EBS on an m1.large instance type. Raw write/fsync operations were on the order of 1.99 msec which is quite fast. A discussion of this can be found in this [AWS Forum thread|http://developer.amazonwebservices.com/connect/thread.jspa?messageID=111957&#111957].
    Charles Lamb

    Morgan,
    Yes, we currently plan to only offer replication for Java 1.5. Our motivations are split between the speed consideration and the codeline issues. We've seen better performance with 1.5. Also taking full advantage of the type safety and concurrent support in 1.5 can end up affecting implementation choices significantly, and can make 1.4 code and 1.5 code diverge a lot.
    As for bug fixing on the 1.4 releases, we don't yet have an official plan. We care very much about supporting our open source users and have been able to provide backwards patches where critical in the past. However, the cost of backporting between 1.5 and 1.4 may be high for some bug fixes, and we'll probably have to decide case by case.
    Regards,
    Linda

  • Can multiple threads share the same cursor in berkeley db java edition?

    We use berkeley db to store our path computation results. We now have two threads which need to retrieve records from database. Specifically, the first thread accesses the database from the very beginning and read a certain number of records. Then, the second thread needs to access the database and read the rest records starting from the position where the cursor stops in the first thread. But, now, I cannot let these two threads share the same cursor. So, I have to open the database separately in two threads and use individual cursor for each thread. This means I have to in the second thread let the cursor skip the first certain number of records and then read the rest records. However, in this way, it is a waste of time letting the second thread skip a certain of records. It will be ideal for us that the second thread can start reading the record just from the place where the first thread stops. Actually, I have tried using transactional cursor and wanted to let the two threads share the same transactional cursor. But it seems that this didn't work.
    Can anyone give any suggestion? Thank you so much!
    sgao

    If your question is really about using the BDB Java Edition product please post to the JE forum:
    Berkeley DB Java Edition
    If your question is about using the Java API of the BDB (C-based) product, then this is the correct forum.
    --mark                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

  • Using Oracle Berkeley DB Java Edition RELEASE 3.2

    Hi,
    I am completely new to Oracle. I intend to use Oracle Berkeley DB Java Edition RELEASE 3.2., in conjunction with Java.
    Can some one help me figure out what documentation I should use, and the learning path ?
    Any suggestions would be greatly appreciated.
    Thanks
    Ravi Banthia
    Kolkata

    Please refer
    http://www.oracle.com/technology/products/berkeley-db/je/index.html

  • Patch Release: Berkeley DB Java Edition 4.0.117

    Berkeley DB Java Edition 4.0.117
    http://www.oracle.com/us/products/database/berkeley-db/index.html
    http://www.oracle.com/technetwork/database/berkeleydb/overview/index.html
    http://www.oracle.com/technetwork/database/berkeleydb/overview/persistence-160890.html
    http://www.oracle.com/technetwork/database/berkeleydb/overview/index-093405.html
    Berkeley DB Java Edition 4.0.117 is a patch release consisting of many important fixes. We strongly recommend that users of the 4.0.x upgrade to this release. Those using 4.1.x need not be concerned with this patch release.
    The critical patch fixes:
    [#19422] - Fixes a bug that prevents recovery if CacheMode.EVICT_BIN is used.
    The complete list of changes is in the change log page.
    http://download.oracle.com/otndocs/products/berkeleydb/html/je/je-40117-changelog.html
    Product documentation can be found at:
    http://download.oracle.com/docs/cd/E17277_02/html/index.html
    Download the source code including the pre-compiled JAR, complete documentation, and the entire test suite as a single package.
    http://download.oracle.com/berkeley-db/je-4.0.117.zip
    http://download.oracle.com/berkeley-db/je-4.0.117.tar.gz
    Common questions are addressed in our FAQ that you can find here:
    http://www.oracle.com/technetwork/database/berkeleydb/je-faq-096044.html
    Then join OTN and participate in the Berkeley DB JE Support Forum discussions. Our engineering and support staff are highly active on these forums, if you have questions please ask them there first.
    Berkeley DB Java Edition
    For further information, or questions about licensing and sales of JE, please contact us at:
    mailto:[email protected]
    Thank you for your support of Berkeley DB Java Edition.

    Hi Kristoffer,
    We have never updated Maven central -- I think someone else, perhaps who is reading the forum, did that for 5.0.73.  We should update it, but we don't quite have our act together on that.  Hopefully we'll have more info on that soon, but for now you'll need to just copy the jar file or use the Oracle maven repo.
    You should definitely read the release notes and the change log, and decide whether to upgrade.
    BDB has both a commercial and an OSS license.  Due to Oracle policy BDB does not have some of the things you might expect from an OSS project:
    - bug system is not exposed
    - roadmap is not published
    - code contributions are fairly rare, mostly due to the nature of the code -- it's a database engine, and is fairly difficult to change casually.
    What other questions about the process do you have?  I wasn't sure exactly what you wanted to know.
    --mark

  • Oracle Berkeley DB Java Edition High Availability (White Paper)

    Hi all,
    I've just read Oracle Berkeley DB Java Edition High Availability White Paper
    http://www.oracle.com/technetwork/database/berkeleydb/berkeleydb-je-ha-whitepaper-132079.pdf
    In section "Time Consistency Policy" (Page 18) it is written:
    "Setting a lag period that is too small, given the load and available hardware resources, could result in
    frequent timeout exceptions and reduce a replica's availability for read operations. It could also increase
    the latency associated with read requests, as the replica makes the read transaction wait so that it can
    catch up in the replication stream."
    Can you tell me why those read operations will not be taken by the master ?
    Why will we have frequent timeout ?
    Why should read transaction wait instead of being redirect to the master ?
    Why should it reduce replica's availability for read operations ?
    Thanks

    Please post this question on the Berkeley DB Java Edition (BDB JE) forum Berkeley DB Java Edition. This is the Berkeley DB Core (BDB) forum.
    Thanks,
    Andrei

  • Berkeley DB Java Edition 3.3.69 is available

    Berkeley DB Java Edition (JE) 3.3.69 is now available for download. The release contains a number of bug fixes, some to problems posted on the OTN forum. The full list of changes may be found in the change log.
    <br>
    <br>
    There is one critical bug fix in this release, described in the change log as follows:
    <br>
    <br>
    "Fix a bug that prevents opening an Environment as read-only under certain circumstances, or causes queries in a read-only Environment to return out of date, and possibly transactionally incorrect, data. The LogFileNotFoundException may be thrown when the problem occurs. [#16368]"
    <br>
    <br>
    This is a fix to a bug that was introduced in JE 3.3.62. If you are currently using 3.3.62 and you are opening the Environment read-only or using the DbDump utility (which opens the Environment read-only), then we strongly recommend that you upgrade to JE 3.3.69.
    <br>
    <br>
    The corresponding Maven POM will be available in a few days.
    <br>
    <br>
    If you are using the JE wrapper plugin for your own Eclipse plugin development AND you open the Environment read-only, you should update that package through
    download.oracle.com/berkeley-db/eclipse. Other DPL Assistant users can consider the update to be optional.

    Morgan,
    Yes, we currently plan to only offer replication for Java 1.5. Our motivations are split between the speed consideration and the codeline issues. We've seen better performance with 1.5. Also taking full advantage of the type safety and concurrent support in 1.5 can end up affecting implementation choices significantly, and can make 1.4 code and 1.5 code diverge a lot.
    As for bug fixing on the 1.4 releases, we don't yet have an official plan. We care very much about supporting our open source users and have been able to provide backwards patches where critical in the past. However, the cost of backporting between 1.5 and 1.4 may be high for some bug fixes, and we'll probably have to decide case by case.
    Regards,
    Linda

  • Berkeley DB Java Edition 3.3.62 is available

    All,
    Berkeley DB Java Edition (JE) 3.3.62 is now available for download at http://www.oracle.com/technology/software/products/berkeley-db/je/index.html . The release contains new features and bug fixes, many in response to questions and requests posted on this forum. Thanks to all for your help in reporting problems, describing use cases, and patiently waiting for features to appear.
    There's improvements in performance, cache management and memory and disk space utilization. Highlights include:
    * Multiple JE environments can now share the same cache to make better use of memory.
    * The deferred write mode can be configured to differentiate between truly temporary databases and databases which should be persistent.
    * Better cache management for large numbers of databases.
    * Per operation caching policy.
    * Key prefixing.
    * Performance improvements.
    Note that JE 3.3.62 introduces a forward-compatible on-disk file format change from JE 3.2. And for the first time, this release introduces a binary and API incompatibility that will hopefully affect few of you. The full list of changes may be found at http://www.oracle.com/technology/documentation/berkeley-db/je/changeLog.html
    We welcome your continued feedback on the product and feature requests.
    Regards,
    The JE team

    Morgan,
    Yes, we currently plan to only offer replication for Java 1.5. Our motivations are split between the speed consideration and the codeline issues. We've seen better performance with 1.5. Also taking full advantage of the type safety and concurrent support in 1.5 can end up affecting implementation choices significantly, and can make 1.4 code and 1.5 code diverge a lot.
    As for bug fixing on the 1.4 releases, we don't yet have an official plan. We care very much about supporting our open source users and have been able to provide backwards patches where critical in the past. However, the cost of backporting between 1.5 and 1.4 may be high for some bug fixes, and we'll probably have to decide case by case.
    Regards,
    Linda

  • Can Berkeley DB Java Edition read BDB created with C

    Hi,
    If I use C to create a BDB database and store the values. Can I use Berkeley DB Java Edition to open and read the content? I am trying to do search and reversed order display and it seems like only DB java Edition has that feature.
    Is that correct?
    Thanks for all your help and suggestion.
    juan

    Hello,
    You will not be able to do that. BDB Java Edition and Berkeley DB are not the same product.
    Thanks,
    Sandra

  • Berkeley DB Java Edition and Android 0.9

    The steps for using JE with Android have changed with Android 0.9 Beta. The revised HOWTO can be found at:
    [http://blogs.oracle.com/charlesLamb/2008/09/berkeley_db_java_edition_and_a_1.html|http://blogs.oracle.com/charlesLamb/2008/09/berkeley_db_java_edition_and_a_1.html]
    Thanks to Tao for working on this.
    Charles Lamb

    Morgan,
    Yes, we currently plan to only offer replication for Java 1.5. Our motivations are split between the speed consideration and the codeline issues. We've seen better performance with 1.5. Also taking full advantage of the type safety and concurrent support in 1.5 can end up affecting implementation choices significantly, and can make 1.4 code and 1.5 code diverge a lot.
    As for bug fixing on the 1.4 releases, we don't yet have an official plan. We care very much about supporting our open source users and have been able to provide backwards patches where critical in the past. However, the cost of backporting between 1.5 and 1.4 may be high for some bug fixes, and we'll probably have to decide case by case.
    Regards,
    Linda

  • Berkeley DB Java Edition - multiple threads accessing database

    Hi,
    I would like to access (read & write) a Berkeley DB from multiple threads (all same process/jvm).
    Should I use a single com.sleepycat.je.Database object for all threads, or should I create an instance for each?
    Or is there any other way of doing it?
    Thanks

    The Database object may be used by multiple threads, so you can use a single instance or multiple ones, as best suits you. From http://docs.oracle.com/cd/E17277_02/html/java/com/sleepycat/je/Database.html,
    Database handles are free-threaded and may be used concurrently by multiple threads. 'If you read through the javadoc, you'll find other notes on using classes from multiple threads.
    Regards,
    Linda

  • Question on implementing a Berkeley DB Java Edition solution

    Hi,
    I am trying to assess if Berkeley DB JE is the solution to my problem. I have couple RDBMS tables that stores user security Groups and Resource relationship recursively in a tree data structure.
    I have an online security api for online applications that supports read only functionality and a admin security api for business system applications for write/update functionality. Currently the online api has to recursively query the database to build the complete group and resource tree structure for a user trying to login, and the performance is horrible for a user with Group sets since it query the database repetitively; or when a several concurrent users try to log in.
    I was thinking of loading the two tables in memory using Berkley DB JE during application start up to remove the overhead of connection to an RDMS. But I want to know what can I do to keep the Berkley DB in sync with the RDMS for if any updates are being made to the RDBS by the admin API.?
    I'm using Oracle 10g and querying using 'connect by' didn’t help wither
    Any advice, suggestion or alternate solution would be helpful
    Mo

    Mo,
    In my case a single application is launched on
    different app servers and I’m planning on using JE asa RDBMS cache, but since JE log files will be created
    on on each app server, over time they will be out of
    sync as the app on each server will be updating their
    individual JE log file. Yes, in this scenario, there are multiple JE read/write environments
    (which would be called databases, in Oracle terms), and they are
    independent. There is no way to built in way to keep multiple
    read/write environments in sync. I do wonder why that's an issue,
    because it sounds like these JE environments are all fed from the
    common RDBMS server, and therefore would hold the same data, but
    that's in your application realm.
    JE allows only a single process to write to the environment. In a
    JavaEE environment we recommend implementing a singleton service that
    is used to access the JE environment, for example, a stateless session
    bean that provides your application specific "data service". Other
    processes (or other J2EE components) should access JE via this data
    service. The data service should provide high level application
    operations, not individual get/put operations, to reduce communication
    overhead. In your case, this doesn't sound sufficient because
    you're using multiple app servers.
    It is possible for other processes to open the JE environment
    read-only, but these are very limited in capability. Changes made by
    the writer process are not visible in the reader process, unless the
    reader process closes and re-opens the Environment, which is
    expensive. In addition, if the processes are on different machines
    you'll need to use a network file system of some kind to access the JE
    environment directory. You can use a network file system for the JE
    environment, but you'll get much better performance by putting it on a
    local disk where the singleton service is running. See the caveats in
    our FAQ if you use a network file system.
    A High Availability (HA) version of JE, i.e., replication, is planned
    for a future release. This will allow multiple reader processes to
    use JE that do not have the limitations I described above, but still
    only a single writer process. Fail over and load balancing (for
    scalability) can be implemented using the HA version.
    ... then may be I could have a new table in the RDMS that keep
    tracks of the set record keys that have been added/updated by the
    admin API, and have the JE application query that table from time to
    time to see if something changed and update its JE store using the DB
    Load functionality ... so this is more of a hybrid solution.Yes, this is a possibility. DbLoad is a bulk load though, and in your
    case you may need to think about how to only add the recent changes,
    and whether you're inserting new data, or also updating existing records.
    Regards,
    Linda

  • Berkeley DB Java Edition 3.2.74 available

    All,
    <p>
    We've put out patch release 3.2.74. The download can be found <a
    href="http://www.oracle.com/technology/software/products/berkeley-db/je/index.html">
    here</a> and the change log describes the bug fixes contained in the release. We recommend that everyone upgrade to this release.
    <p>
    Regards,
    <br>
    Linda

    All,
    <p>
    We've put out patch release 3.2.74. The download can be found <a
    href="http://www.oracle.com/technology/software/products/berkeley-db/je/index.html">
    here</a> and the change log describes the bug fixes contained in the release. We recommend that everyone upgrade to this release.
    <p>
    Regards,
    <br>
    Linda

Maybe you are looking for

  • Can I Use The iPhoto4 "Picture Browser" Without Copying The Photos?

    I use Photoshop Elements 2 for serious editing. However, I find the Browser rather pathetic (small and slow) compared with iPhoto4's. iPhoto's picture viewer is really excellent, enabling me to view albums at any size virtually instantly. Unfortunate

  • Online discounts vs. instore price

    I know when we first came to Verizon about 8 years ago, the policy was that if you mentioned an online discount at the store they were able to honor that price instore.  Is this still the case?  We are eligible for our NE2 tomorrow and if I do the on

  • Incorrect password for user account SLDDSUSERSMD (USER_OR_PASSWORD_INCORREC

    Hello I am installing Java add In in Solution manager 4.0, Central Instance. The process stops in this step: Mar 12, 2007 10:56:58... Info: User management tool (com.sap.security.tools.UserCheck) called for action "checkCreate" Mar 12, 2007 10:56:58.

  • Connected to internet via ethernet but server not responding

    I have browsed some threads on this topic but none gave me an answer, and my set up is not quite the same as those that I've read. I don't want to hijack another thread and confuse the readers. I would be very grateful for help on this issue. I have

  • Which apps most affected by graphics card?

    Trying to understand which non-game apps are likely to perform better with a high end graphics card vs my stock FX5200. The description of the x800 XT says it's good for content creation apps "such as" Motion, Modo, and Maya. Does that mean any 3D/an