Skip to content

Commit

Permalink
releasing OrientDB 2.1.12
Browse files Browse the repository at this point in the history
  • Loading branch information
robfrank committed Mar 1, 2016
2 parents 3099f6a + 2d02ced commit 818ff28
Show file tree
Hide file tree
Showing 89 changed files with 4,625 additions and 650 deletions.
2 changes: 1 addition & 1 deletion client/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
<parent>
<groupId>com.orientechnologies</groupId>
<artifactId>orientdb-parent</artifactId>
<version>2.1.11</version>
<version>2.1.12</version>
<relativePath>../</relativePath>
</parent>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
*/
package com.orientechnologies.orient.client.remote;

import com.orientechnologies.common.concur.lock.OModificationLock;
import com.orientechnologies.common.concur.lock.OModificationOperationProhibitedException;
import com.orientechnologies.common.exception.OException;
import com.orientechnologies.common.io.OIOException;
Expand Down Expand Up @@ -239,6 +240,14 @@ public void open(final String iUserName, final String iUserPassword, final Map<S
}
}

/**
* {@inheritDoc}
*/
@Override
public OModificationLock getModificationLock() {
return null;
}

public void reload() {

stateLock.acquireWriteLock();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
import java.util.concurrent.Callable;
import java.util.concurrent.atomic.AtomicInteger;

import com.orientechnologies.common.concur.lock.OModificationLock;
import com.orientechnologies.orient.core.Orient;
import com.orientechnologies.orient.core.command.OCommandOutputListener;
import com.orientechnologies.orient.core.command.OCommandRequestText;
Expand Down Expand Up @@ -92,6 +93,14 @@ public void open(final String iUserName, final String iUserPassword, final Map<S
}
}

/**
* {@inheritDoc}
*/
@Override
public OModificationLock getModificationLock() {
return null;
}

@Override
public boolean isDistributed() {
return delegate.isDistributed();
Expand Down
2 changes: 1 addition & 1 deletion core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
<parent>
<groupId>com.orientechnologies</groupId>
<artifactId>orientdb-parent</artifactId>
<version>2.1.11</version>
<version>2.1.12</version>
<relativePath>../</relativePath>
</parent>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
package com.orientechnologies.orient.core;

public class OConstants {
public static final String ORIENT_VERSION = "2.1.11";
public static final String ORIENT_VERSION = "2.1.12";

public static final String ORIENT_URL = "www.orientdb.com";
public static final String COPYRIGHT = "Copyrights (c) 2015 Orient Technologies LTD";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,13 @@
*/
package com.orientechnologies.orient.core.collate;

import com.orientechnologies.orient.core.index.OCompositeKey;
import com.orientechnologies.common.comparator.ODefaultComparator;

import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;

/**
* Case insensitive collate.
*
Expand All @@ -39,6 +43,21 @@ public Object transform(final Object obj) {
if (obj instanceof String)
return ((String) obj).toLowerCase();

if(obj instanceof Set){
Set result = new HashSet();
for(Object o:(Set)obj){
result.add(transform(o));
}
return result;
}

if(obj instanceof List){
List result = new ArrayList();
for(Object o:(List)obj){
result.add(transform(o));
}
return result;
}
return obj;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,10 +125,27 @@ public void change(Object currentValue, Object newValue) {
DISK_CACHE_FREE_SPACE_LIMIT("storage.diskCache.diskFreeSpaceLimit",
"Minimum amount of space on disk after which database will " + "work only in read mode, in megabytes", Long.class, 100),

@Deprecated

DISC_CACHE_FREE_SPACE_CHECK_INTERVAL("storage.diskCache.diskFreeSpaceCheckInterval",
"Interval, in seconds, after which storage periodically "
+ "checks whether amount of free space enough to work in write mode",
Integer.class, 5),
"The interval (in seconds), after which the storage periodically "
+ "checks whether the amount of free disk space is enough to work in write mode", Integer.class, 5),

/**
* The interval (how many new pages should be added before free space will be checked), after which the storage periodically
* checks whether the amount of free disk space is enough to work in write mode.
*/
DISC_CACHE_FREE_SPACE_CHECK_INTERVAL_IN_PAGES("storage.diskCache.diskFreeSpaceCheckIntervalInPages",
"The interval (how many new pages should be added before free space will be checked), after which the storage periodically "
+ "checks whether the amount of free disk space is enough to work in write mode", Integer.class, 4096),

/**
* Keep disk cache state between moment when storage is closed and moment when it is opened again.
* <code>true</code> by default.
*/
STORAGE_KEEP_DISK_CACHE_STATE("storage.diskCache.keepState",
"Keep disk cache state between moment when storage is closed and moment when it is opened again. true by default.",
Boolean.class, true),

STORAGE_CONFIGURATION_SYNC_ON_UPDATE("storage.configuration.syncOnUpdate",
"Should we perform force sync of storage configuration for each update", Boolean.class, true),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
*/
package com.orientechnologies.orient.core.db;

import com.orientechnologies.common.log.OLogManager;
import com.orientechnologies.orient.core.OOrientListenerAbstract;
import com.orientechnologies.orient.core.Orient;
import com.orientechnologies.orient.core.db.document.ODatabaseDocumentTx;
Expand All @@ -35,39 +36,39 @@
* <p>
* Lock free implementation of database pool which has good multicore scalability characteristics.
* </p>
*
* <p>
* <p>
* Because pool is lock free it means that if connection pool exhausted it does not wait till free connections are released but
* throws exception instead (this is going to be fixed in next versions, by using version of pool with 3 parameters, minimum pool
* size, maximum pool size, maximum pool size under load, so pool will keep amount records from minimum to maxmimum value but under
* high load it will be allowed to extend amount of connections which it keeps till maximum size under load value and then amount of
* records in pool will be decreased).
* </p>
*
* <p>
* <p>
* But increase in consumption of JVM resources because of addition of new more database instance with the same url and the same
* user is very small.
* </p>
*
* <p>
* <p>
* To acquire connection from the pool call {@link #acquire()} method but to release connection you just need to call
* {@link com.orientechnologies.orient.core.db.document.ODatabaseDocument#close()} method.
* </p>
*
* <p>
* <p>
* In case of remote storage database pool will keep connections to the remote storage till you close pool. So in case of remote
* storage you should close pool at the end of it's usage, it also may be closed on application shutdown but you should not rely on
* this behaviour.
* </p>
*
* <p>
* <p>
* </p>
* This pool has one noticeable difference from other pools. If you perform several subsequent acquire calls in the same thread the
* <b>same</b> instance of database will be returned, but amount of calls to close method should match to amount of acquire calls to
* release database back in the pool. It will allow you to use such feature as transaction propagation when you perform call of one
* service from another one.
* </p>
*
* <p>
* <p>
* </p>
* Given pool has only one parameter now, amount of maximum connections for single partition. When you start to use pool it will
Expand All @@ -84,22 +85,22 @@ public class OPartitionedDatabasePool extends OOrientListenerAbstract {
private static final int HASH_INCREMENT = 0x61c88647;
private static final int MIN_POOL_SIZE = 2;
private static final AtomicInteger nextHashCode = new AtomicInteger();
private final String url;
private final String userName;
private final String password;
private final int maxSize;
private final String url;
private final String userName;
private final String password;
private final int maxSize;

private volatile ThreadLocal<PoolData> poolData = new ThreadPoolData();
private final AtomicBoolean poolBusy = new AtomicBoolean();
private final int maxPartitions = Runtime.getRuntime().availableProcessors() << 3;
private volatile PoolPartition[] partitions;
private volatile boolean closed = false;
private boolean autoCreate = false;
private final AtomicBoolean poolBusy = new AtomicBoolean();
private final int maxPartitions = Runtime.getRuntime().availableProcessors() << 3;
private volatile PoolPartition[] partitions;
private volatile boolean closed = false;
private boolean autoCreate = false;

private static final class PoolData {
private final int hashCode;
private int acquireCount;
private DatabaseDocumentTxPolled acquiredDatabase;
private final int hashCode;
private int acquireCount;
private DatabaseDocumentTxPolled acquiredDatabase;

private PoolData() {
hashCode = nextHashCode();
Expand Down Expand Up @@ -155,11 +156,30 @@ public void close() {
PoolPartition p = partition;
partition = null;

super.close();
final OStorage storage = getStorage();
//if connection is lost and storage is closed as result we should not put closed connection back to the pool
if (!storage.isClosed()) {
super.close();

data.acquiredDatabase = null;

p.queue.offer(this);
} else {
//close database instance but be ready that it will throw exception because of storage is closed
try {
super.close();
} catch (Exception e) {
OLogManager.instance().error(this, "Error during closing of database % when storage %s was already closed", e, getUrl(),
storage.getName());
}

data.acquiredDatabase = null;

data.acquiredDatabase = null;
//we create new connection instead of old one
final DatabaseDocumentTxPolled db = new DatabaseDocumentTxPolled(url);
p.queue.offer(db);
}

p.queue.offer(this);
p.acquiredConnections.decrementAndGet();
} else {
super.close();
Expand Down Expand Up @@ -332,6 +352,10 @@ public OPartitionedDatabasePool setAutoCreate(final boolean autoCreate) {
return this;
}

public boolean isClosed() {
return closed;
}

protected void openDatabase(final DatabaseDocumentTxPolled db) {
if (autoCreate) {
if (!db.getURL().startsWith("remote:") && !db.exists()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,29 +31,26 @@

/**
* Factory for {@link OPartitionedDatabasePool} pool, which also works as LRU cache with good mutlicore architecture support.
*
* <p>
* In case of remote storage database pool will keep connections to the remote storage till you close pool. So in case of remote
* storage you should close pool factory at the end of it's usage, it also may be closed on application shutdown but you should not
* rely on this behaviour.
*
*
* @author Andrey Lomakin (a.lomakin-at-orientechnologies.com)
* @since 06/11/14
*/
public class OPartitionedDatabasePoolFactory extends OOrientListenerAbstract {
private volatile int maxPoolSize = 64;
private boolean closed = false;
private volatile int maxPoolSize = 64;
private boolean closed = false;

private final ConcurrentLinkedHashMap<PoolIdentity, OPartitionedDatabasePool> poolStore;

private final EvictionListener<PoolIdentity, OPartitionedDatabasePool> evictionListener = new EvictionListener<PoolIdentity, OPartitionedDatabasePool>() {
@Override
public void onEviction(
PoolIdentity poolIdentity,
OPartitionedDatabasePool partitionedDatabasePool) {
partitionedDatabasePool
.close();
}
};
private final EvictionListener<PoolIdentity, OPartitionedDatabasePool> evictionListener = new EvictionListener<PoolIdentity, OPartitionedDatabasePool>() {
@Override
public void onEviction(PoolIdentity poolIdentity, OPartitionedDatabasePool partitionedDatabasePool) {
partitionedDatabasePool.close();
}
};

public OPartitionedDatabasePoolFactory() {
this(100);
Expand Down Expand Up @@ -83,16 +80,28 @@ public OPartitionedDatabasePool get(String url, String userName, String userPass
final PoolIdentity poolIdentity = new PoolIdentity(url, userName, userPassword);

OPartitionedDatabasePool pool = poolStore.get(poolIdentity);
if (pool != null)
if (pool != null && !pool.isClosed())
return pool;

pool = new OPartitionedDatabasePool(url, userName, userPassword, maxPoolSize);
if (pool != null)
poolStore.remove(poolIdentity, pool);

final OPartitionedDatabasePool oldPool = poolStore.putIfAbsent(poolIdentity, pool);
if (oldPool != null)
return oldPool;
while (true) {
pool = new OPartitionedDatabasePool(url, userName, userPassword, maxPoolSize);

final OPartitionedDatabasePool oldPool = poolStore.putIfAbsent(poolIdentity, pool);

if (oldPool != null) {
if (!oldPool.isClosed()) {
return oldPool;
} else {
poolStore.remove(poolIdentity, oldPool);
}
} else {
return pool;
}
}

return pool;
}

public Collection<OPartitionedDatabasePool> getPools() {
Expand Down

0 comments on commit 818ff28

Please sign in to comment.