Skip to content

Commit

Permalink
Issue #4284 is fixed.
Browse files Browse the repository at this point in the history
  • Loading branch information
andrii0lomakin committed Jun 6, 2015
1 parent 8b495ff commit cecc1fc
Show file tree
Hide file tree
Showing 10 changed files with 238 additions and 198 deletions.
67 changes: 37 additions & 30 deletions core/src/main/java/com/orientechnologies/orient/core/engine/OEngineAbstract.java
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,43 +1,50 @@
/*
*
* * Copyright 2014 Orient Technologies LTD (info(at)orientechnologies.com)
* *
* * Licensed under the Apache License, Version 2.0 (the "License");
* * you may not use this file except in compliance with the License.
* * You may obtain a copy of the License at
* *
* * http://www.apache.org/licenses/LICENSE-2.0
* *
* * Unless required by applicable law or agreed to in writing, software
* * distributed under the License is distributed on an "AS IS" BASIS,
* * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* * See the License for the specific language governing permissions and
* * limitations under the License.
* *
* * For more information: http://www.orientechnologies.com
*
*/
*
* * Copyright 2014 Orient Technologies LTD (info(at)orientechnologies.com)
* *
* * Licensed under the Apache License, Version 2.0 (the "License");
* * you may not use this file except in compliance with the License.
* * You may obtain a copy of the License at
* *
* * http://www.apache.org/licenses/LICENSE-2.0
* *
* * Unless required by applicable law or agreed to in writing, software
* * distributed under the License is distributed on an "AS IS" BASIS,
* * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* * See the License for the specific language governing permissions and
* * limitations under the License.
* *
* * For more information: http://www.orientechnologies.com
*
*/
package com.orientechnologies.orient.core.engine;

import java.util.Map;

import com.orientechnologies.orient.core.storage.OStorage;
import com.orientechnologies.orient.core.storage.cache.OSnowFlakeIdGen;
import com.orientechnologies.orient.core.storage.cache.OWriteCacheIdGen;

public abstract class OEngineAbstract implements OEngine {
private static final OWriteCacheIdGen writeCacheIdGen = new OSnowFlakeIdGen();

protected String getMode(Map<String, String> iConfiguration) {
String dbMode = null;
if (iConfiguration != null)
dbMode = iConfiguration.get("mode");
protected int generateStorageId() {
return writeCacheIdGen.nextId();
}

if (dbMode == null)
dbMode = "rw";
return dbMode;
}
protected String getMode(Map<String, String> iConfiguration) {
String dbMode = null;
if (iConfiguration != null)
dbMode = iConfiguration.get("mode");

public void shutdown() {
}
if (dbMode == null)
dbMode = "rw";
return dbMode;
}

public void removeStorage(final OStorage iStorage) {
}
public void shutdown() {
}

public void removeStorage(final OStorage iStorage) {
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -38,18 +38,17 @@
* @since 28.03.13
*/
public class OEngineLocalPaginated extends OEngineAbstract {
public static final String NAME = "plocal";
public static final String NAME = "plocal";

private final OWriteCacheIdGen writeCacheIdGen = new OSnowFlakeIdGen();
private final OReadCache readCache = new O2QCache(
(long) (OGlobalConfiguration.DISK_CACHE_SIZE.getValueAsLong() * 1024 * 1024 * ((100 - OGlobalConfiguration.DISK_WRITE_CACHE_PART
.getValueAsInteger()) / 100.0)), OGlobalConfiguration.DISK_CACHE_PAGE_SIZE
.getValueAsInteger() * 1024, true);
private final OReadCache readCache = new O2QCache(
(long) (OGlobalConfiguration.DISK_CACHE_SIZE.getValueAsLong() * 1024 * 1024 * ((100 - OGlobalConfiguration.DISK_WRITE_CACHE_PART
.getValueAsInteger()) / 100.0)), OGlobalConfiguration.DISK_CACHE_PAGE_SIZE
.getValueAsInteger() * 1024, true);

public OStorage createStorage(final String dbName, final Map<String, String> configuration) {
try {
// GET THE STORAGE
return new OLocalPaginatedStorage(dbName, dbName, getMode(configuration), writeCacheIdGen.nextId(), readCache);
return new OLocalPaginatedStorage(dbName, dbName, getMode(configuration), generateStorageId(), readCache);

} catch (Throwable t) {
OLogManager.instance().error(this,
Expand Down
70 changes: 35 additions & 35 deletions core/src/main/java/com/orientechnologies/orient/core/engine/memory/OEngineMemory.java
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
/*
*
* * Copyright 2014 Orient Technologies LTD (info(at)orientechnologies.com)
* *
* * Licensed under the Apache License, Version 2.0 (the "License");
* * you may not use this file except in compliance with the License.
* * You may obtain a copy of the License at
* *
* * http://www.apache.org/licenses/LICENSE-2.0
* *
* * Unless required by applicable law or agreed to in writing, software
* * distributed under the License is distributed on an "AS IS" BASIS,
* * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* * See the License for the specific language governing permissions and
* * limitations under the License.
* *
* * For more information: http://www.orientechnologies.com
*
*/
*
* * Copyright 2014 Orient Technologies LTD (info(at)orientechnologies.com)
* *
* * Licensed under the Apache License, Version 2.0 (the "License");
* * you may not use this file except in compliance with the License.
* * You may obtain a copy of the License at
* *
* * http://www.apache.org/licenses/LICENSE-2.0
* *
* * Unless required by applicable law or agreed to in writing, software
* * distributed under the License is distributed on an "AS IS" BASIS,
* * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* * See the License for the specific language governing permissions and
* * limitations under the License.
* *
* * For more information: http://www.orientechnologies.com
*
*/
package com.orientechnologies.orient.core.engine.memory;

import java.util.Map;
Expand All @@ -28,25 +28,25 @@
import com.orientechnologies.orient.core.storage.impl.memory.ODirectMemoryStorage;

public class OEngineMemory extends OEngineAbstract {
public static final String NAME = "memory";
public static final String NAME = "memory";

public OEngineMemory() {
}
public OEngineMemory() {
}

public OStorage createStorage(String url, Map<String, String> configuration) {
try {
return new ODirectMemoryStorage(url, url, getMode(configuration));
} catch (Throwable t) {
OLogManager.instance().error(this, "Error on opening in memory storage: " + url, t, ODatabaseException.class);
}
return null;
}
public OStorage createStorage(String url, Map<String, String> configuration) {
try {
return new ODirectMemoryStorage(url, url, getMode(configuration), generateStorageId());
} catch (Throwable t) {
OLogManager.instance().error(this, "Error on opening in memory storage: " + url, t, ODatabaseException.class);
}
return null;
}

public String getName() {
return NAME;
}
public String getName() {
return NAME;
}

public boolean isShared() {
return true;
}
public boolean isShared() {
return true;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
import com.orientechnologies.orient.core.exception.OStorageException;
import com.orientechnologies.orient.core.metadata.schema.OType;
import com.orientechnologies.orient.core.serialization.serializer.binary.OBinarySerializerFactory;
import com.orientechnologies.orient.core.storage.cache.OAbstractWriteCache;
import com.orientechnologies.orient.core.storage.cache.OWriteCache;
import com.orientechnologies.orient.core.storage.fs.OFileClassic;
import com.orientechnologies.orient.core.storage.impl.local.OLowDiskSpaceInformation;
Expand All @@ -54,7 +55,7 @@
* @author Andrey Lomakin
* @since 7/23/13
*/
public class OWOWCache implements OWriteCache, OCachePointer.WritersListener {
public class OWOWCache extends OAbstractWriteCache implements OWriteCache, OCachePointer.WritersListener {
// we add 8 bytes before and after cache pages to prevent word tearing in mt case.

private final int MAX_PAGES_PER_FLUSH;
Expand Down Expand Up @@ -1112,18 +1113,6 @@ private void flushPage(int fileId, long pageIndex, ODirectMemoryPointer dataPoin
fileClassic.synch();
}

private static long composeFileId(int id, int fileId) {
return (((long) id) << 32) | fileId;
}

public static int extractFileId(long fileId) {
return (int) (fileId & 0xFFFFFFFFL);
}

public static int extractStorageId(long fileId) {
return (int) (fileId >>> 32);
}

private static final class NameFileIdEntry {
private final String name;
private final int fileId;
Expand Down Expand Up @@ -1263,7 +1252,6 @@ public void run() {
if (flushedPages < writePagesToFlush && forceFlush) {
flushedPages = flushRing(writePagesToFlush, flushedPages, true, iterateByWritePagesFirst);


if (flushedPages < writePagesToFlush && iterateByWritePagesFirst) {
flushRing(writePagesToFlush, flushedPages, true, false);

Expand Down
Loading

0 comments on commit cecc1fc

Please sign in to comment.