Hi,

Do you see anything on the server log ?
Your session may be killed if something wrong happen server side.

bye
Emanuel


On 02/03/15 14:50, Ivan Jovanovic wrote:
Hello everyone,

I am using a OrientDB Community 2.0.3 in my application in order to store PDF documents with some additional attached properties. Every user will have its own Vertex (class Client), each document will be represented as a Vertex (class Document), its thumbnail as well (class Thumbnail), and there will exist an "Owns" edge between between Client and Document, and "Rendition" edge between Document and Thumbnail;

When I start the application try to process a number of files (let's say 50 or 100) one by one, the application, after some time during writing the files (which appears to be random) loses connection to the database with the following error:

WARNUNG: Caught I/O errors, trying to reconnect (error: com.orientechnologies.common.io.OIOException: Cannot open a connection to remote server: 127.0.0.1:2424/attachments)

The connection never recovers! This is the only message that I see, the log is empty, and the try/catch block which surrounds the code does not catch any exceptions.

I am posting the relevant code below:

    private OrientGraphFactory factory;


    public void initialize() {

try {
StringBuilder builder = new StringBuilder();
builder.append(SERVER_URL);
builder.append('/');
builder.append(DB_NAME);
OServerAdmin serverAdmin = new OServerAdmin(builder.toString()).connect(USERNAME, PASSWORD);
if(!serverAdmin.existsDatabase("plocal")) {
serverAdmin.createDatabase("graph", "plocal");
OrientGraphFactory factory = new OrientGraphFactory(builder.toString(), USERNAME, PASSWORD);
OrientGraphNoTx graph = factory.getNoTx();
OrientVertexType clientVertex = graph.createVertexType(CLIENT_CLASS);
OrientVertexProperty guidProperty = clientVertex.createProperty(GUID_PARAMETER, OType.STRING);
guidProperty.setMandatory(true);
guidProperty.setNotNull(true);

OrientVertexType documentVertex = graph.createVertexType(DOCUMENT_CLASS);
OrientVertexProperty documentGuidProperty = documentVertex.createProperty(GUID_PARAMETER, OType.STRING);
documentGuidProperty.setMandatory(true);
documentGuidProperty.setNotNull(false);
OrientVertexProperty filenameProperty = documentVertex.createProperty(FILENAME_PARAMETER, OType.STRING);
filenameProperty.setMandatory(true);
filenameProperty.setNotNull(true);

OrientVertexProperty creationDateProperty = documentVertex.createProperty(CREATION_DATE_PARAMETER, OType.DATETIME);
creationDateProperty.setMandatory(true);
creationDateProperty.setNotNull(true);

OrientVertexProperty descriptionProperty = documentVertex.createProperty(DESCRIPTION_PARAMETER, OType.STRING);
descriptionProperty.setMandatory(false);
descriptionProperty.setNotNull(false);
OrientVertexProperty numPagesProperty = documentVertex.createProperty(NUM_PAGES_PARAMETER, OType.INTEGER);
numPagesProperty.setMandatory(true);
numPagesProperty.setNotNull(true);

OrientVertexProperty fiscalYearProperty = documentVertex.createProperty(FISCAL_YEAR_PARAMETER, OType.STRING);
fiscalYearProperty.setMandatory(true);
fiscalYearProperty.setNotNull(true);

OrientVertexProperty categoryParameter = documentVertex.createProperty(CATEGORY_PARAMETER, OType.STRING);
categoryParameter.setMandatory(false);
categoryParameter.setNotNull(false);

OrientVertexProperty codeParameter = documentVertex.createProperty(CODE_PARAMETER, OType.STRING);
codeParameter.setMandatory(false);
codeParameter.setNotNull(false);

OrientVertexProperty clientCopyParameter = documentVertex.createProperty(CLIENT_COPY_PARAMETER, OType.BOOLEAN);
clientCopyParameter.setMandatory(true);

OrientVertexProperty taxAdministratorCopyParameter = documentVertex.createProperty(TAX_ADMINISTRATOR_COPY_PARAMETER, OType.BOOLEAN);
taxAdministratorCopyParameter.setMandatory(true);

OrientVertexProperty archiveCopyParameter = documentVertex.createProperty(ARCHIVE_COPY_PARAMETER, OType.BOOLEAN);
archiveCopyParameter.setMandatory(true);

OrientVertexProperty processedParameter = documentVertex.createProperty(PROCESSED_PARAMETER, OType.BOOLEAN);
processedParameter.setMandatory(true);

OrientVertexProperty contentParameter = documentVertex.createProperty(CONTENT_PARAMETER, OType.LINK);
contentParameter.setMandatory(true);
contentParameter.setNotNull(true);

OrientVertexType thumbnailVertex = graph.createVertexType(THUMBNAIL_CLASS); OrientVertexProperty thumbnailContentParameter = thumbnailVertex.createProperty(CONTENT_PARAMETER, OType.LINK);
thumbnailContentParameter.setMandatory(true);
thumbnailContentParameter.setNotNull(true);

graph.createEdgeType(OWNS_EDGE);
graph.createEdgeType(RENDITION_EDGE);
graph.shutdown();
}
}
catch(Exception e) {
e.printStackTrace();
}

        factory = new OrientGraphFactory(builder.toString(), USERNAME,
        PASSWORD);

    ODatabaseRecordThreadLocal.INSTANCE.set(factory.getDatabase());

    }



    private Vertex getClientVertex(OrientGraph graph, String guid) {

Vertex clientVertex = null;
Iterable<Vertex> vertices = graph.query().has(GUID_PARAMETER, guid).vertices();
if(vertices.iterator().hasNext()) {
clientVertex = vertices.iterator().next();
}
else {
clientVertex = graph.addVertex("class:Client");
clientVertex.setProperty(GUID_PARAMETER, guid);
graph.commit();
}

return clientVertex;

    }

    public void writeDocument(String filename, Date dateCreated,
    String category, String guid, byte[] contents, int pageCount,
    String description, String code, String fiscalYear, boolean

    taxAdministratorsCopy, boolean clientsCopy, boolean archivesCopy,
    boolean processed) {

    OrientGraph graph = factory.getTx();
    try {
    Vertex clientVertex = getClientVertex(graph, guid);
    OrientVertex documentVertex = graph.addVertex("class:Document");
    documentVertex.setProperty(FILENAME_PARAMETER, filename);
    documentVertex.setProperty(GUID_PARAMETER, guid);
    documentVertex.setProperty(CREATION_DATE_PARAMETER, dateCreated);
    if(description != null) {
    documentVertex.setProperty(DESCRIPTION_PARAMETER, description);
    }
    documentVertex.setProperty(NUM_PAGES_PARAMETER, pageCount);
    documentVertex.setProperty(FISCAL_YEAR_PARAMETER, fiscalYear);
    if(category != null) {
    documentVertex.setProperty(CATEGORY_PARAMETER, category);
    }
    if(code != null) {
    documentVertex.setProperty(CODE_PARAMETER, code);
    }
    documentVertex.setProperty(TAX_ADMINISTRATOR_COPY_PARAMETER,
    taxAdministratorsCopy);
    documentVertex.setProperty(CLIENT_COPY_PARAMETER, clientsCopy);
    documentVertex.setProperty(ARCHIVE_COPY_PARAMETER, archivesCopy);
    documentVertex.setProperty(PROCESSED_PARAMETER, processed);
    ORecordBytes record = new ORecordBytes(contents);
    record.save();
    documentVertex.setProperty(CONTENT_PARAMETER, record.getIdentity());

    Object id = documentVertex.getId();
    documentVertex = graph.getVertex(id);
    graph.addEdge("class:E", clientVertex, documentVertex, OWNS_EDGE);

        // Thumbnail generation code...


    OrientVertex thumbnailVertex = graph.addVertex("class:Thumbnail");
    ORecordBytes thumbnailRecord = new ORecordBytes(thumbnail);
    thumbnailRecord.save();
    thumbnailVertex.setProperty(CONTENT_PARAMETER,
    thumbnailRecord.getIdentity());

    Object thumbnailId = thumbnailVertex.getId();
    thumbnailVertex = graph.getVertex(thumbnailId);
    graph.addEdge("class:E", documentVertex, thumbnailVertex,
    RENDITION_EDGE);
    }
    catch(Exception e) {
    e.printStackTrace();
    }
    graph.shutdown();
    }



What am I doing wrong here?

Many thanks for your help, it is much appreciated.

Ivan
--

---
You received this message because you are subscribed to the Google Groups "OrientDB" group. To unsubscribe from this group and stop receiving emails from it, send an email to orient-database+unsubscr...@googlegroups.com <mailto:orient-database+unsubscr...@googlegroups.com>.
For more options, visit https://groups.google.com/d/optout.

--

--- You received this message because you are subscribed to the Google Groups "OrientDB" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to orient-database+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to