I am currently working in Scala, and I have some unit tests set up to work
on a remote server. Currently the test is set to create the database if it
doesn't exist, then if it created to run a series of sql commands on it to
initialize the database to have the classes, properties, and such that I
need.
Occasionally during the initialization it will fail out with a number of
different reasons. So far here's a list of the exceptions that have been
caught:
All of these have a "Future timed out" exception during my initdb. I have
60 seconds for the future to complete which should be magnitudes longer
than required.
Before init is called I check if the databases exist, and then drop if so,
I also drop at the end of tests to have a known good state. The drop before
is in case of failure to complete the test and not get to clean up.
Here is a list of failure reasons returned over a series of about 100
iterations. The timing out seems to be the most common one, seeming like
some sort of race condition that is happening and deadlocking during
creation or initialization of the database.
The test framework always fails during the beforeAll phase where the below
code is called. If the initialization goes through without a problem the
tests will pass every time.
Failures:
1. This one had no further exceptions just failed all of my tests.
This time the database was created successfully.
2. OStorageException: Storage remotedb is not opened
3. OStorageException: Error executing command: sql.CREATE PROPERTY
autoincrement.nextid INTEGER.
Caused by java.net.SocketException: Socket Closed
4. OIndexException: Error on rebuilding the index for clusters:
[device]
Caused by:
com.orientechnologies.orient.core.exception.OStorageException: Storage
remotedb is not opened.
5. Another OStorageException: Storage remotedb is not opened
6. Many more with no further exceptions, just times out at:
Await.ready(f, 20 second). Again the database was created successfully
according to server logs.
Code:
def db: ODatabaseDocumentTx = new ODatabaseDocumentTx(connection) //where
connection is a string in the form of: remote:<host>:<port>/<dbname>
val serverAdmin = new OServerAdmin(connection)
def sqlinit() = {
val init_sql = List(
"CREATE CLASS device",
"CREATE PROPERTY device.id INTEGER",
"CREATE PROPERTY device.serial STRING",
"CREATE INDEX idx ON device (id) UNIQUE_HASH_INDEX",
"CREATE INDEX device.serial UNIQUE",
"CREATE CLASS autoincrement",
"CREATE PROPERTY autoincrement.nextid INTEGER",
"INSERT INTO autoincrement SET nextid=1"
)
init_sql.foreach( (sql: String) => {
val request : OCommandRequest = db.command( new OCommandSQL(sql) )
request.execute()
() // Unit returning function need this instead of having
request.execute as last function.
})
}
def open = {
val dbUser = dbConfig.getString("user")
val dbPass = dbConfig.getString("pass")
db.open(dbUser, dbPass)
}
def close = db.close
def initdb = {
val f = future {
try {
serverAdmin.connect(srvUser,srvPass)
if(!serverAdmin.existsDatabase) {
serverAdmin.createDatabase("document","plocal").close
open
sqlinit()
close
}
else {
serverAdmin.close
}
} catch {
case e: Exception => {
e.printStackTrace()
throw e
}
}
}
Await.ready(f, 60 second)
}
--
---
You received this message because you are subscribed to the Google Groups
"OrientDB" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.