You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jackrabbit.apache.org by sh...@apache.org on 2015/05/08 10:21:08 UTC
svn commit: r1678302 - in /jackrabbit/trunk/jackrabbit-data/src:
main/java/org/apache/jackrabbit/core/data/
test/java/org/apache/jackrabbit/core/data/ test/resources/
Author: shashank
Date: Fri May 8 08:21:07 2015
New Revision: 1678302
URL: http://svn.apache.org/r1678302
Log:
JCR-3881 Change CachingFDS configuration properties
Fixed. Currently CachingFDS is configured from 'path' property which collide with CachingDataStore's path property in OSGI configuration where both properties reside in same osgi config.
Changed path property to 'fsBackendPath'
Modified:
jackrabbit/trunk/jackrabbit-data/src/main/java/org/apache/jackrabbit/core/data/FSBackend.java
jackrabbit/trunk/jackrabbit-data/src/test/java/org/apache/jackrabbit/core/data/TestCachingFDS.java
jackrabbit/trunk/jackrabbit-data/src/test/java/org/apache/jackrabbit/core/data/TestCachingFDSCacheOff.java
jackrabbit/trunk/jackrabbit-data/src/test/java/org/apache/jackrabbit/core/data/TestFileDataStore.java
jackrabbit/trunk/jackrabbit-data/src/test/resources/fs.properties
Modified: jackrabbit/trunk/jackrabbit-data/src/main/java/org/apache/jackrabbit/core/data/FSBackend.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-data/src/main/java/org/apache/jackrabbit/core/data/FSBackend.java?rev=1678302&r1=1678301&r2=1678302&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-data/src/main/java/org/apache/jackrabbit/core/data/FSBackend.java (original)
+++ jackrabbit/trunk/jackrabbit-data/src/main/java/org/apache/jackrabbit/core/data/FSBackend.java Fri May 8 08:21:07 2015
@@ -45,7 +45,7 @@ public class FSBackend implements Backen
private Properties properties;
- private String path;
+ private String fsPath;
private CachingDataStore store;
@@ -53,11 +53,11 @@ public class FSBackend implements Backen
private String config;
- File pathDir;
+ File fsPathDir;
private ThreadPoolExecutor asyncWriteExecuter;
- public static final String PATH = "path";
+ public static final String FS_BACKEND_PATH = "fsBackendPath";
/**
* Logger instance.
@@ -100,21 +100,21 @@ public class FSBackend implements Backen
throws DataStoreException {
this.store = store;
this.homeDir = homeDir;
- this.path = prop.getProperty(PATH);
- if (this.path == null || "".equals(this.path)) {
+ this.fsPath = prop.getProperty(FS_BACKEND_PATH);
+ if (this.fsPath == null || "".equals(this.fsPath)) {
throw new DataStoreException("Could not initialize FSBackend from "
- + config + ". [" + PATH + "] property not found.");
+ + config + ". [" + FS_BACKEND_PATH + "] property not found.");
}
- pathDir = new File(this.path);
- if (pathDir.exists() && pathDir.isFile()) {
+ fsPathDir = new File(this.fsPath);
+ if (fsPathDir.exists() && fsPathDir.isFile()) {
throw new DataStoreException("Can not create a directory "
- + "because a file exists with the same name: " + this.path);
+ + "because a file exists with the same name: " + this.fsPath);
}
- if( !pathDir.exists()) {
- boolean created = pathDir.mkdirs();
+ if (!fsPathDir.exists()) {
+ boolean created = fsPathDir.mkdirs();
if (!created) {
throw new DataStoreException("Could not create directory: "
- + pathDir.getAbsolutePath());
+ + fsPathDir.getAbsolutePath());
}
}
asyncWriteExecuter = (ThreadPoolExecutor) Executors.newFixedThreadPool(
@@ -172,8 +172,10 @@ public class FSBackend implements Backen
try {
FileUtils.copyFile(src, dest);
} catch (IOException ioe) {
+ LOG.error("failed to copy [{}] to [{}]",
+ src.getAbsolutePath(), dest.getAbsolutePath());
throw new DataStoreException("Not able to write file ["
- + identifier + "]");
+ + identifier + "]", ioe);
}
}
}
@@ -209,7 +211,7 @@ public class FSBackend implements Backen
public Iterator<DataIdentifier> getAllIdentifiers()
throws DataStoreException {
ArrayList<File> files = new ArrayList<File>();
- for (File file : pathDir.listFiles()) {
+ for (File file : fsPathDir.listFiles()) {
if (file.isDirectory()) { // skip top-level files
listRecursive(files, file);
}
@@ -298,7 +300,7 @@ public class FSBackend implements Backen
public Set<DataIdentifier> deleteAllOlderThan(long min)
throws DataStoreException {
Set<DataIdentifier> deleteIdSet = new HashSet<DataIdentifier>(30);
- for (File file : pathDir.listFiles()) {
+ for (File file : fsPathDir.listFiles()) {
if (file.isDirectory()) { // skip top-level files
deleteOlderRecursive(file, min, deleteIdSet);
}
@@ -340,7 +342,7 @@ public class FSBackend implements Backen
*/
private File getFile(DataIdentifier identifier) {
String string = identifier.toString();
- File file = this.pathDir;
+ File file = this.fsPathDir;
file = new File(file, string.substring(0, 2));
file = new File(file, string.substring(2, 4));
file = new File(file, string.substring(4, 6));
@@ -418,7 +420,7 @@ public class FSBackend implements Backen
// Only iterate & delete if parent directory of the blob file is
// child
// of the base directory and if it is empty
- while (FileUtils.directoryContains(pathDir, parent)) {
+ while (FileUtils.directoryContains(fsPathDir, parent)) {
String[] entries = parent.list();
if (entries == null) {
LOG.warn("Failed to list directory {}",
Modified: jackrabbit/trunk/jackrabbit-data/src/test/java/org/apache/jackrabbit/core/data/TestCachingFDS.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-data/src/test/java/org/apache/jackrabbit/core/data/TestCachingFDS.java?rev=1678302&r1=1678301&r2=1678302&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-data/src/test/java/org/apache/jackrabbit/core/data/TestCachingFDS.java (original)
+++ jackrabbit/trunk/jackrabbit-data/src/test/java/org/apache/jackrabbit/core/data/TestCachingFDS.java Fri May 8 08:21:07 2015
@@ -38,16 +38,16 @@ public class TestCachingFDS extends Test
protected DataStore createDataStore() throws RepositoryException {
CachingFDS cacheFDS = new CachingFDS();
Properties props = loadProperties("/fs.properties");
- String pathValue = props.getProperty("path");
+ String pathValue = props.getProperty(FSBackend.FS_BACKEND_PATH);
if (pathValue != null && !"".equals(pathValue.trim())) {
- path = pathValue + "/cachingFds" + "-"
+ fsPath = pathValue + "/cachingFds" + "-"
+ String.valueOf(randomGen.nextInt(100000)) + "-"
+ String.valueOf(randomGen.nextInt(100000));
} else {
- path = dataStoreDir + "/cachingFds";
+ fsPath = dataStoreDir + "/cachingFds";
}
- props.setProperty("path", path);
- LOG.info("path [{}] set.", path);
+ props.setProperty(FSBackend.FS_BACKEND_PATH, fsPath);
+ LOG.info("fsBackendPath [{}] set.", fsPath);
cacheFDS.setProperties(props);
cacheFDS.setSecret("12345");
cacheFDS.init(dataStoreDir);
@@ -79,5 +79,4 @@ public class TestCachingFDS extends Test
fail(e.getMessage());
}
}
-
}
Modified: jackrabbit/trunk/jackrabbit-data/src/test/java/org/apache/jackrabbit/core/data/TestCachingFDSCacheOff.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-data/src/test/java/org/apache/jackrabbit/core/data/TestCachingFDSCacheOff.java?rev=1678302&r1=1678301&r2=1678302&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-data/src/test/java/org/apache/jackrabbit/core/data/TestCachingFDSCacheOff.java (original)
+++ jackrabbit/trunk/jackrabbit-data/src/test/java/org/apache/jackrabbit/core/data/TestCachingFDSCacheOff.java Fri May 8 08:21:07 2015
@@ -27,19 +27,19 @@ import org.slf4j.LoggerFactory;
public class TestCachingFDSCacheOff extends TestFileDataStore {
protected static final Logger LOG = LoggerFactory.getLogger(TestCachingFDS.class);
-
+
protected DataStore createDataStore() throws RepositoryException {
CachingFDS cacheFDS = new CachingFDS();
Properties props = loadProperties("/fs.properties");
- String pathValue = props.getProperty("path");
+ String pathValue = props.getProperty(FSBackend.FS_BACKEND_PATH);
if (pathValue != null && !"".equals(pathValue.trim())) {
- path = pathValue + "/cachingFds" + "-"
+ fsPath = pathValue + "/cachingFds" + "-"
+ String.valueOf(randomGen.nextInt(100000)) + "-"
+ String.valueOf(randomGen.nextInt(100000));
} else {
- path = dataStoreDir + "/cachingFDS";
+ fsPath = dataStoreDir + "/cachingFDS";
}
- props.setProperty("path", path);
+ props.setProperty(FSBackend.FS_BACKEND_PATH, fsPath);
cacheFDS.setProperties(props);
cacheFDS.setSecret("12345");
cacheFDS.setCacheSize(0);
Modified: jackrabbit/trunk/jackrabbit-data/src/test/java/org/apache/jackrabbit/core/data/TestFileDataStore.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-data/src/test/java/org/apache/jackrabbit/core/data/TestFileDataStore.java?rev=1678302&r1=1678301&r2=1678302&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-data/src/test/java/org/apache/jackrabbit/core/data/TestFileDataStore.java (original)
+++ jackrabbit/trunk/jackrabbit-data/src/test/java/org/apache/jackrabbit/core/data/TestFileDataStore.java Fri May 8 08:21:07 2015
@@ -33,30 +33,30 @@ public class TestFileDataStore extends T
protected static final Logger LOG = LoggerFactory.getLogger(TestFileDataStore.class);
- protected String path;
+ String fsPath;
@Override
protected DataStore createDataStore() throws RepositoryException {
FileDataStore fds = new FileDataStore();
Properties props = loadProperties("/fs.properties");
- String pathValue = props.getProperty("path");
+ String pathValue = props.getProperty(FSBackend.FS_BACKEND_PATH);
if (pathValue != null && !"".equals(pathValue.trim())) {
- path = pathValue + "/fds" + "-"
+ fsPath = pathValue + "/fds" + "-"
+ String.valueOf(randomGen.nextInt(100000)) + "-"
+ String.valueOf(randomGen.nextInt(100000));
} else {
- path = dataStoreDir + "/repository/datastore";
+ fsPath = dataStoreDir + "/repository/datastore";
}
- LOG.info("path [{}] set.", path);
- fds.setPath(path);
+ LOG.info("path [{}] set.", fsPath);
+ fds.setPath(fsPath);
fds.init(dataStoreDir);
return fds;
}
@Override
protected void tearDown() {
- LOG.info("cleaning path [{}]", path);
- File f = new File(path);
+ LOG.info("cleaning fsPath [{}]", fsPath);
+ File f = new File(fsPath);
try {
for (int i = 0; i < 4 && f.exists(); i++) {
FileUtils.deleteQuietly(f);
@@ -67,5 +67,4 @@ public class TestFileDataStore extends T
}
super.tearDown();
}
-
}
Modified: jackrabbit/trunk/jackrabbit-data/src/test/resources/fs.properties
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-data/src/test/resources/fs.properties?rev=1678302&r1=1678301&r2=1678302&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-data/src/test/resources/fs.properties (original)
+++ jackrabbit/trunk/jackrabbit-data/src/test/resources/fs.properties Fri May 8 08:21:07 2015
@@ -14,4 +14,4 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#
-
+fsBackendPath=