cancel
Showing results for 
Search instead for 
Did you mean: 

How to make custom DB driver for JLAN-server ?

dhant
Champ on-the-rise
Champ on-the-rise

Hi All.

I am trying make new simple DB-driver for JLAN-server. This DB-driver different from other implementations

(such as OracleDBInterface, MysqlDBInterface, PostgesqlDBInterface). My DB-driver will use full path to target file.

Existing DB-drivers (for Oracle, Mysql, Postgres) use "virtual file system" consisting of DirID and FileID.

For my DB-driver this method not suitable.

I need help!!

How to determine full path to target file or directory, that requested user (through SMB,FTP or NFS client)?

Please specify the specific java-class or method from source code Jlan-server.

I would be grateful for a simple example of using this java-class or method.

Thank you in advance for your help.

8 REPLIES 8

afaust
Legendary Innovator
Legendary Innovator

I am afraid barely anyone is using the JLAN library in a stand-alone and low-level manner like that, and you might not find any help for this question. The primary use with relation to Alfresco is as an internal file server component and almost all of the community is using it as-is.

From what I undestand of the SMB protocol, the communication is primarily based on ID-based file/folder handles. A full path is typically not exchanged in a network packet as this would be quite wasteful (single ID = one or two bytes, full path = technically unlimited length). This explains why all the existing DB drivers use DirID and FileID instead of a path. Per definition of the DBInterface interface, it is the responsibility of the DB driver to convert a DirID and FileID to a FileInfo, which in turn contains a fullPath. So it seems impossible to write a DB driver that does not use DirID and FileID - no other component will be able to resolve those to a full path instead.

Since Alfresco integrated the JLAN project into its ECM product / project structure, the core library really hasn't seen much work in terms of feature enhancements. Most of the work has been applied to the specific use cases for integration in other Alfresco projects, e.g. alfresco-repository. The JLAN library has not seen an independant release since 2009. I thought you should be aware that you are working with a somewhat stale library.

dhant
Champ on-the-rise
Champ on-the-rise

Axel, thanks for the reply.

Internal file server "Alfresco" has a newer version of a library than a standalone "JLAN-server"?

Standalone "JLAN-server" not release since 2009? Source code "JLAN server" accessible from two resources:

https://github.com/OpenDataSpace/jlan

https://svn.alfresco.com/repos/alfresco-open-mirror/services/jlan/

The last modification date in SVN is unknown. The last modification date on github - 30 Jun 2016. At the moment, "JLAN-server" supports SMB v2.

This version of the Protocol is obsolete (current version SMB v3 for OS Windows), but is supported by most  OS.

Regarding file descriptors:

For convert a full path to the file\directory in the handle file\directory (FileID\DirID)  suitable use the hash to string.

Example:

            int pathCode = "/home/userlogin/docum/mainfile".hashCode();

            System.out.println("handle file or directory = " + pathCode);

            // handle file or directory = 1313579302

At the moment I have a deeper understanding of "Jlan server" than at the time of creating this post.

Later I can write what I managed to understand and do within my task.

afaust
Legendary Innovator
Legendary Innovator

The source code from OpenDataSpace appears to be a fork of the library code.

The Alfresco JLAN library in the Alfresco SVN definitely does NOT support SMB 2 or any newer version, which is one of the various complaints people in the community raise with Alfresco. The internal library is definitely "newer" than the one on SourceForge from 2009 but changes should be primarily about bugfixes, not real innovation.

hashCode() is not a suitable conversion operation for turning a path into a unique identifier. Different paths can result in identical hash values.

dhant
Champ on-the-rise
Champ on-the-rise

Axel, Yes, I was wrong.

"Windows Server 2012" detects  the version of the Jlan-SMB as 1.5 (used  the command PowerShell "Get-SmbConnection" ).

However, I have not noticed any problem when using the Jlan server as an SMB drive.

I used the function "hashCode()" for the example. Of course, in the hash by string can be conflicts. But the percentage of collisions would be roughly one in a million.

It will not be a problem if not to store millions of files in one directory (this will be a "super cloud for big data").

dhant
Champ on-the-rise
Champ on-the-rise

Hello.


I did the first implementation of its DB-driver. Currently implemented display of files and directories, and the ability to open files for reading.

I had to face one challenge - update state of the temporary file in "DBFileLoader.java". By default, the temporary file becomes obsolete with the passage of time (according to the timeout). For this reason, the temporary file may be different from a file in the repository until it is removed from the "temp" and re-loaded. I do not know at what point do I need to check the temporary file on the relevance (to remove obsolete files and download new).

I leave this comment, in order to attract interested developers.

Thanks in advance for your reply.

dviswanath
Champ in-the-making
Champ in-the-making

Hi Dilan,

Can you please provide some sample code of what you have done so that I can check for my usecase and one more thing is were you able to add the repository as network drive or how you are trying to edit/ view files

Thanks in advance

dhant
Champ on-the-rise
Champ on-the-rise

Hi.

Unfortunately at the moment I can not show their code.
I try create my DB-driver for Oracle. My driver will save files via JDBC on the server's file system (not in the database tables, as is currently done in JlanDBDrivers). To do this, I replaced the inside interfaces for the database Oracle SQL-calls to PL\SQL-calls.
The whole point is that my PLSQL-call returns the same set of data, which returns SQL-call from the DB-table.
In your case, instead PLSQL-call will be called Web-service (if I have correctly understood your task).
For simple implementation of file sharing you will need to create a Web service (Web-API), which will return interfaces the data from the three special tables:

1) The table structure of files and directories. This table should be generated dynamically for each directory (for example: the contents of the directory "/home/user1", will be different from the contents of the "/var/lib"). I recommend creating FileId and DirId using a hash on the string (full path for file or directories). They must be unique. The rest of the information you can extract from your repository (web-api).

==== FileSysTable =====
FileId NUMBER PRIMARY KEY,
DirId NUMBER,
FileName VARCHAR2(255) NOT NULL,
FileSize NUMBER,
CreateDate TIMESTAMP,
ModifyDate TIMESTAMP,
AccessDate TIMESTAMP,
ChangeDate TIMESTAMP,
ReadOnlyFile NUMBER(1),
ArchivedFile NUMBER(1),
DirectoryFile NUMBER(1),
SystemFile NUMBER(1),
HiddenFile NUMBER(1),
IsSymLink NUMBER(1),
OwnerUid NUMBER(6),
OwnerGid NUMBER(6),
FileMode NUMBER(6),
IsDeleted NUMBER(1) DEFAULT 0;


2) Table of contents of a file (binary data). This table is extracted contents of the file when it is downloading. The contents of the file is stored in the "Blob".

==== DataTable =====
FileId NUMBER NOT NULL,
StreamId NUMBER NOT NULL,
FragNo NUMBER,
FragLen NUMBER,
Data BLOB,
JarFile CHAR(1),
JarId NUMBER;

3) Table of queue downloads. Your boot loader will not necessarily been supporting queue. This table is stored line information about segment file to download. Need just implement the temporary storage of such data.

==== QueueTable =====
FileId NUMBER NOT NULL,
StreamId INTEGER NOT NULL,
ReqType NUMBER(2),
SeqNo NUMBER PRIMARY KEY,
TempFile VARCHAR2(512),
VirtualPath VARCHAR2(512),
QueuedAt TIMESTAMP,
Attribs VARCHAR(512);

Web-API need simulate interfaces of DB-table, example "HTTP-get json or xml" instead "select * from FileSysTable" (At least I think so).

The names of these tables are specified in the configuration file "jlanConfig.xml":

<DatabaseInterface>
  <class>org.alfresco.jlan.server.filesys.db.oracle.OracleDBInterface</class>
  <FileSystemTable>FileSysTable</FileSystemTable>
  <DataTable>DataTable</DataTable>
  <QueueTable>QueueTable</QueueTable>
  <SQLDebug/>
</DatabaseInterface>

I would recommend you connect Jlan-server to the database (postgress or oracle), then turn on the option <SQLDebug />.
This will help to find answers to some questions.

At the moment, I can plug my DB-storage as a network drive (SMB\NFS\FTP). The files are read-only. Editing and saving is not yet implemented.

dhant
Champ on-the-rise
Champ on-the-rise

There is an example HTTP-driver implementations for JLan-server, look here (project Liferay-CIFS).