use of org.apache.commons.vfs2.FileSystemManager in project wso2-synapse by wso2.
the class VFSTransportSenderTest method getSoftReferenceMap.
private Map<?, ?> getSoftReferenceMap(VFSTransportSender vfsTransportSender) throws NoSuchFieldException, IllegalAccessException {
Field field = VFSTransportSender.class.getDeclaredField("fsManager");
field.setAccessible(true);
FileSystemManager fsm = (FileSystemManager) field.get(vfsTransportSender);
FilesCache fileCache = fsm.getFilesCache();
SoftRefFilesCache softRefFilesCache = (SoftRefFilesCache) fileCache;
Field field1 = SoftRefFilesCache.class.getDeclaredField("refReverseMap");
field1.setAccessible(true);
return (Map<?, ?>) (Map) field1.get(softRefFilesCache);
}
use of org.apache.commons.vfs2.FileSystemManager in project wso2-synapse by wso2.
the class VFSUtils method isFailRecord.
public static boolean isFailRecord(FileSystemManager fsManager, FileObject fo) {
try {
String fullPath = fo.getName().getURI();
int pos = fullPath.indexOf("?");
if (pos > -1) {
fullPath = fullPath.substring(0, pos);
}
FileObject failObject = fsManager.resolveFile(fullPath + ".fail");
if (failObject.exists()) {
return true;
}
} catch (FileSystemException e) {
log.error("Couldn't release the fail for the file : " + maskURLPassword(fo.getName().getURI()));
}
return false;
}
use of org.apache.commons.vfs2.FileSystemManager in project wso2-synapse by wso2.
the class VFSUtils method markFailRecord.
public static synchronized void markFailRecord(FileSystemManager fsManager, FileObject fo) {
// generate a random fail value to ensure that there are no two parties
// processing the same file
byte[] failValue = (Long.toString((new Date()).getTime())).getBytes();
try {
String fullPath = fo.getName().getURI();
int pos = fullPath.indexOf("?");
if (pos != -1) {
fullPath = fullPath.substring(0, pos);
}
FileObject failObject = fsManager.resolveFile(fullPath + ".fail");
if (!failObject.exists()) {
failObject.createFile();
}
// write a lock file before starting of the processing, to ensure that the
// item is not processed by any other parties
OutputStream stream = failObject.getContent().getOutputStream();
try {
stream.write(failValue);
stream.flush();
stream.close();
} catch (IOException e) {
failObject.delete();
log.error("Couldn't create the fail file before processing the file " + maskURLPassword(fullPath), e);
} finally {
failObject.close();
}
} catch (FileSystemException fse) {
log.error("Cannot get the lock for the file : " + maskURLPassword(fo.getName().getURI()) + " before processing");
}
}
use of org.apache.commons.vfs2.FileSystemManager in project pentaho-platform by pentaho.
the class PentahoXmlaServlet method makeCatalogLocator.
@Override
protected CatalogLocator makeCatalogLocator(ServletConfig servletConfig) {
return new ServletContextCatalogLocator(servletConfig.getServletContext()) {
@Override
public String locate(String catalogPath) {
if (catalogPath.startsWith("mondrian:")) {
// $NON-NLS-1$
try {
FileSystemManager fsManager = VFS.getManager();
SolutionRepositoryVfsFileObject catalog = (SolutionRepositoryVfsFileObject) fsManager.resolveFile(catalogPath);
catalogPath = "solution:" + catalog.getFileRef();
} catch (FileSystemException e) {
logger.error(e.getMessage());
}
} else {
catalogPath = super.locate(catalogPath);
}
return catalogPath;
}
};
}
use of org.apache.commons.vfs2.FileSystemManager in project accumulo by apache.
the class AccumuloVFSClassLoader method getClassLoader.
public static ClassLoader getClassLoader() throws IOException {
ReloadingClassLoader localLoader = loader;
while (null == localLoader) {
synchronized (lock) {
if (null == loader) {
FileSystemManager vfs = generateVfs();
// Set up the 2nd tier class loader
if (null == parent) {
parent = AccumuloClassLoader.getClassLoader();
}
FileObject[] vfsCP = resolve(vfs, AccumuloClassLoader.getAccumuloProperty(VFS_CLASSLOADER_SYSTEM_CLASSPATH_PROPERTY, ""));
if (vfsCP.length == 0) {
localLoader = createDynamicClassloader(parent);
loader = localLoader;
return localLoader.getClassLoader();
}
// Create the Accumulo Context ClassLoader using the DEFAULT_CONTEXT
localLoader = createDynamicClassloader(new VFSClassLoader(vfsCP, vfs, parent));
loader = localLoader;
// and SequenceFile$Reader was trying to instantiate the key class via WritableName.getClass(String, Configuration)
for (FileObject fo : vfsCP) {
if (fo instanceof HdfsFileObject) {
String uri = fo.getName().getRootURI();
Configuration c = new Configuration(true);
c.set(FileSystem.FS_DEFAULT_NAME_KEY, uri);
FileSystem fs = FileSystem.get(c);
fs.getConf().setClassLoader(loader.getClassLoader());
}
}
}
}
}
return localLoader.getClassLoader();
}
Aggregations