@Test public void testAddOrUpdateArc() throws Exception { storage.addOrUpdateARC(arcFile1); ArcVO arc = storage.getArcByID("arcfile1"); assertEquals(arcFile1, arc.getFileName()); storage.addOrUpdateARC("folder3/folder4/arcfile1"); arc = storage.getArcByID("arcfile1"); assertEquals("folder3/folder4/arcfile1", arc.getFileName()); }
public void addOrUpdateARC(String arcPath) throws Exception { log.info("AddOrUpdateARC arc-file: " + arcPath); String[] splitPath = splitPath(arcPath); String folder = splitPath[0]; String arcId = splitPath[1]; boolean aRCIDExist = aRCIDExist(arcId); PreparedStatement stmt = null; try { if (aRCIDExist){ log.info("Updating folder for arc-file: " + arcPath); stmt = connection.prepareStatement(changeArcFolderStatement); stmt.setString(1, folder); stmt.setLong(2, System.currentTimeMillis()); stmt.setString(3, arcId); int updated = stmt.executeUpdate(); if (updated == 0){ throw new IllegalArgumentException("Arcfile not found with id:"+arcId); } } else{ log.info("Persisting new arc-file: " + arcPath); stmt = connection.prepareStatement(addArcStatement); long now = System.currentTimeMillis(); stmt.setString(1, arcId); stmt.setString(2, folder); stmt.setLong(3, now); stmt.setInt(4,5); stmt.setString(5,"NEW"); stmt.setLong(6,now); stmt.execute(); } } catch (Exception e) { log.error("SQL Exception in addOrUpdateARC:" + e.getMessage()); throw e; } finally { closeStatement(stmt); } }
ArchonStorage { public void addOrUpdateARC(String arcPath) throws Exception { log.info("AddOrUpdateARC arc-file: " + arcPath); String[] splitPath = splitPath(arcPath); String folder = splitPath[0]; String arcId = splitPath[1]; boolean aRCIDExist = aRCIDExist(arcId); PreparedStatement stmt = null; try { if (aRCIDExist){ log.info("Updating folder for arc-file: " + arcPath); stmt = connection.prepareStatement(changeArcFolderStatement); stmt.setString(1, folder); stmt.setLong(2, System.currentTimeMillis()); stmt.setString(3, arcId); int updated = stmt.executeUpdate(); if (updated == 0){ throw new IllegalArgumentException("Arcfile not found with id:"+arcId); } } else{ log.info("Persisting new arc-file: " + arcPath); stmt = connection.prepareStatement(addArcStatement); long now = System.currentTimeMillis(); stmt.setString(1, arcId); stmt.setString(2, folder); stmt.setLong(3, now); stmt.setInt(4,5); stmt.setString(5,"NEW"); stmt.setLong(6,now); stmt.execute(); } } catch (Exception e) { log.error("SQL Exception in addOrUpdateARC:" + e.getMessage()); throw e; } finally { closeStatement(stmt); } } }
ArchonStorage { public void addOrUpdateARC(String arcPath) throws Exception { log.info("AddOrUpdateARC arc-file: " + arcPath); String[] splitPath = splitPath(arcPath); String folder = splitPath[0]; String arcId = splitPath[1]; boolean aRCIDExist = aRCIDExist(arcId); PreparedStatement stmt = null; try { if (aRCIDExist){ log.info("Updating folder for arc-file: " + arcPath); stmt = connection.prepareStatement(changeArcFolderStatement); stmt.setString(1, folder); stmt.setLong(2, System.currentTimeMillis()); stmt.setString(3, arcId); int updated = stmt.executeUpdate(); if (updated == 0){ throw new IllegalArgumentException("Arcfile not found with id:"+arcId); } } else{ log.info("Persisting new arc-file: " + arcPath); stmt = connection.prepareStatement(addArcStatement); long now = System.currentTimeMillis(); stmt.setString(1, arcId); stmt.setString(2, folder); stmt.setLong(3, now); stmt.setInt(4,5); stmt.setString(5,"NEW"); stmt.setLong(6,now); stmt.execute(); } } catch (Exception e) { log.error("SQL Exception in addOrUpdateARC:" + e.getMessage()); throw e; } finally { closeStatement(stmt); } } ArchonStorage(); }
ArchonStorage { public void addOrUpdateARC(String arcPath) throws Exception { log.info("AddOrUpdateARC arc-file: " + arcPath); String[] splitPath = splitPath(arcPath); String folder = splitPath[0]; String arcId = splitPath[1]; boolean aRCIDExist = aRCIDExist(arcId); PreparedStatement stmt = null; try { if (aRCIDExist){ log.info("Updating folder for arc-file: " + arcPath); stmt = connection.prepareStatement(changeArcFolderStatement); stmt.setString(1, folder); stmt.setLong(2, System.currentTimeMillis()); stmt.setString(3, arcId); int updated = stmt.executeUpdate(); if (updated == 0){ throw new IllegalArgumentException("Arcfile not found with id:"+arcId); } } else{ log.info("Persisting new arc-file: " + arcPath); stmt = connection.prepareStatement(addArcStatement); long now = System.currentTimeMillis(); stmt.setString(1, arcId); stmt.setString(2, folder); stmt.setLong(3, now); stmt.setInt(4,5); stmt.setString(5,"NEW"); stmt.setLong(6,now); stmt.execute(); } } catch (Exception e) { log.error("SQL Exception in addOrUpdateARC:" + e.getMessage()); throw e; } finally { closeStatement(stmt); } } ArchonStorage(); static void initialize(String driverName, String driverUrl, String userName, String password); int nextShardId(); void addARC(String arcPath); void addOrUpdateARC(String arcPath); List<String> getShardIDs(); String nextARC(String shardID); List<String> getARCFiles(String shardID); ArcVO getArcByID(String arcID); int getArcCount(); List<ArcVO> getLatest1000Arcs(); List<ArcVO> getAllRunningArcs(); void setARCState(String arcPath, ArchonConnector.ARC_STATE arcState); void setShardState(String shardID, ArchonConnector.ARC_STATE state, int priority); void setARCProperties(String fullPath, String shardID,ArchonConnector.ARC_STATE state, int priority); void setARCPriority(String fullPath, int priority); void resetArcWithPriorityStatement(String fullPath, int priority); void removeARC(String arcID); void clearIndexing(String shardID); void resetShardId(String shardID); void commit(); void rollback(); void close(); static void shutdown(); }
ArchonStorage { public void addOrUpdateARC(String arcPath) throws Exception { log.info("AddOrUpdateARC arc-file: " + arcPath); String[] splitPath = splitPath(arcPath); String folder = splitPath[0]; String arcId = splitPath[1]; boolean aRCIDExist = aRCIDExist(arcId); PreparedStatement stmt = null; try { if (aRCIDExist){ log.info("Updating folder for arc-file: " + arcPath); stmt = connection.prepareStatement(changeArcFolderStatement); stmt.setString(1, folder); stmt.setLong(2, System.currentTimeMillis()); stmt.setString(3, arcId); int updated = stmt.executeUpdate(); if (updated == 0){ throw new IllegalArgumentException("Arcfile not found with id:"+arcId); } } else{ log.info("Persisting new arc-file: " + arcPath); stmt = connection.prepareStatement(addArcStatement); long now = System.currentTimeMillis(); stmt.setString(1, arcId); stmt.setString(2, folder); stmt.setLong(3, now); stmt.setInt(4,5); stmt.setString(5,"NEW"); stmt.setLong(6,now); stmt.execute(); } } catch (Exception e) { log.error("SQL Exception in addOrUpdateARC:" + e.getMessage()); throw e; } finally { closeStatement(stmt); } } ArchonStorage(); static void initialize(String driverName, String driverUrl, String userName, String password); int nextShardId(); void addARC(String arcPath); void addOrUpdateARC(String arcPath); List<String> getShardIDs(); String nextARC(String shardID); List<String> getARCFiles(String shardID); ArcVO getArcByID(String arcID); int getArcCount(); List<ArcVO> getLatest1000Arcs(); List<ArcVO> getAllRunningArcs(); void setARCState(String arcPath, ArchonConnector.ARC_STATE arcState); void setShardState(String shardID, ArchonConnector.ARC_STATE state, int priority); void setARCProperties(String fullPath, String shardID,ArchonConnector.ARC_STATE state, int priority); void setARCPriority(String fullPath, int priority); void resetArcWithPriorityStatement(String fullPath, int priority); void removeARC(String arcID); void clearIndexing(String shardID); void resetShardId(String shardID); void commit(); void rollback(); void close(); static void shutdown(); static Date INITDATE; }