private void selectCommonPhase(int phaseNumber, SimpleXARecoveryHandler[] handlers) throws SimpleXAResourceException { try { for (SimpleXARecoveryHandler handler: handlers) handler.selectPhase(phaseNumber); } catch (IOException ei) { throw new SimpleXAResourceException("IO failure selecting phase on database", ei); } }
private void clearDatabase(SimpleXARecoveryHandler[] handlers) throws SimpleXAResourceException { try { for (SimpleXARecoveryHandler handler: handlers) handler.clear(); } catch (IOException ei) { throw new SimpleXAResourceException("IO failure clearing database", ei); } }
/** * Closes and invalidates the BlankNodeMap and frees any resources associated * with it. * * @throws SimpleXAResourceException */ private void deleteBlankNodeMap() throws SimpleXAResourceException { try { blankNodeMap.close(); blankNodeMap = null; } catch (Exception graphException) { throw new SimpleXAResourceException("Failed to close BlankNodeMap.", graphException); } }
/** * Closes any existing BlankNodeMap and creates a new one. * * @throws SimpleXAResourceException */ private void createBlankNodeMap() throws SimpleXAResourceException { //is there already a map? try { if (blankNodeMap != null) { deleteBlankNodeMap(); } } catch (SimpleXAResourceException resourceException) { throw new SimpleXAResourceException("Failed to delete existing " + "BlankNodeMap.", resourceException); } //create a new one try { blankNodeMap = nodeMapFactory.newBlankNodeMap(); } catch (Exception graphException) { throw new SimpleXAResourceException("Failed to create BlankNodeMap.", graphException); } }
public void rollback() throws SimpleXAResourceException { if (logger.isDebugEnabled()) { logger.debug("Rollback phase on StringPoolSession " + System.identityHashCode(this)); } if (state == RELEASE) { throw new SimpleXAResourceException("Attempting to rollback phase outside transaction"); } state = ROLLBACK; persistentStringPool.rollback(); persistentNodePool.rollback(); for (int i = 0; i < resources.length; i++) { resources[i].rollback(); } }
public void prepare() throws SimpleXAResourceException { if (logger.isDebugEnabled()) { logger.debug("Preparing phase on StringPoolSession " + System.identityHashCode(this) + " SP=" + System.identityHashCode(persistentStringPool)); } if (state == PREPARE) { return; } else if (state != OBTAIN) { throw new SimpleXAResourceException("Attempting to prepare phase without obtaining phase"); } state = PREPARE; persistentStringPool.prepare(); persistentNodePool.prepare(); for (int i = 0; i < resources.length; i++) { resources[i].prepare(); } }
public void commit() throws SimpleXAResourceException { if (logger.isDebugEnabled()) { logger.debug("Committing phase on StringPoolSession " + System.identityHashCode(this)); } if (state == COMMIT) { return; } else if (state != PREPARE) { throw new SimpleXAResourceException("Attempting to commit phase without preparing"); } state = COMMIT; synchronized (globalLock) { persistentStringPool.commit(); persistentNodePool.commit(); for (int i = 0; i < resources.length; i++) { resources[i].commit(); } } }
public void release() throws SimpleXAResourceException { if (logger.isDebugEnabled()) { logger.debug("Release phase on StringPoolSession " + System.identityHashCode(this)); } if (state == RELEASE) { return; } else if (state != COMMIT && state != ROLLBACK) { throw new SimpleXAResourceException("Attempting to release phase without commit or rollback"); } state = RELEASE; persistentStringPool.release(); persistentNodePool.release(); // TODO determine if release() should be called for the temp components. //temporaryStringPool.release(); //temporaryNodePool.release(); for (int i = 0; i < resources.length; i++) { resources[i].release(); } }
if (!prepared) { throw new SimpleXAResourceException( "commit() called without previous prepare()." ); } catch (IOException ex) { logger.fatal("I/O error while performing commit.", ex); throw new SimpleXAResourceException( "I/O error while performing commit.", ex );
if (!prepared) { throw new SimpleXAResourceException( "commit() called without previous prepare()." ); } catch (IOException ex) { logger.fatal("I/O error while performing commit.", ex); throw new SimpleXAResourceException( "I/O error while performing commit.", ex );
private TIntHashSet[] recoverRecoveryHandlers(SimpleXARecoveryHandler[] handlers) throws SimpleXAResourceException { TIntHashSet[] phaseSets = new TIntHashSet[handlers.length]; boolean allEmpty = true; for (int i = 0; i < handlers.length; i++) { phaseSets[i] = new TIntHashSet(handlers[i].recover()); if (!allEmpty && phaseSets[i].isEmpty()) { throw new SimpleXAResourceException("Unable to find common phase in pre-existing database"); } else if (!phaseSets[i].isEmpty()) { allEmpty = false; } } return !allEmpty ? phaseSets : null; }
throw new SimpleXAResourceException( "I/O error while performing rollback (invalidating metaroot)", ex ); new Phase(committedPhaseToken.getPhase()); } catch (IOException ex) { throw new SimpleXAResourceException( "I/O error while performing rollback (new committed phase)", ex );
throw new SimpleXAResourceException( "I/O error while performing rollback (invalidating metaroot)", ex ); currentPhase = freeList.new Phase(committedPhaseToken.getPhase()); } catch (IOException ex) { throw new SimpleXAResourceException( "I/O error while performing rollback (new committed phase)", ex );
/** * Reinitializes the NodePool so that it is empty. This should be called after * constructing a NodePoolImpl when creating a new triple store. * * @param phaseNumber the initial phase number. * @throws IOException if an I/O error occurs. * @throws SimpleXAResourceException if it is inappropriate to call clear() at * this time. */ public synchronized void clear( int phaseNumber ) throws IOException, SimpleXAResourceException { if (currentPhase != null) { throw new IllegalStateException( "NodePool already has a current phase." ); } openMetarootFile(true); try { synchronized (committedPhaseLock) { committedPhaseToken = freeList.new Phase(MIN_NODE).use(); } this.phaseNumber = phaseNumber; phaseIndex = 1; freeList.clear(); } catch (IllegalStateException ex) { throw new SimpleXAResourceException("Cannot initialize free list.", ex); } currentPhase = freeList.new Phase(); }
throw new SimpleXAResourceException("Wrong metaroot file version."); openMetarootFile(false); } catch (IOException ex) { throw new SimpleXAResourceException("I/O error", ex);
throw new SimpleXAResourceException("Wrong metaroot file version."); openMetarootFile(false); } catch (IOException ex) { throw new SimpleXAResourceException("I/O error", ex);
private void recoverDatabase(SimpleXARecoveryHandler[] handlers) throws SimpleXAResourceException { assert handlers != null; TIntHashSet[] phaseSets = recoverRecoveryHandlers(handlers); if (phaseSets == null) { clearDatabase(handlers); } else { TIntHashSet phaseSet = intersectPhaseSets(phaseSets); if (phaseSet.isEmpty()) { throw new SimpleXAResourceException("No matching phases between Resource Handlers."); } selectCommonPhase(highestCommonPhaseNumber(phaseSet), handlers); } }
public int[] recover() throws SimpleXAResourceException { int[] nodePhases = persistentNodePool.recover(); int[] stringPhases = persistentStringPool.recover(); // If both are empty then return empty. if (nodePhases.length == 0 && stringPhases.length == 0) { return nodePhases; } // Else if the intersection is empty *error*, TIntHashSet phaseSet = new TIntHashSet(nodePhases); phaseSet.retainAll(stringPhases); if (phaseSet.isEmpty()) { throw new SimpleXAResourceException("No matching phases between Node and String Pools."); } //else return the intersection. return phaseSet.toArray(); }
throw new SimpleXAResourceException("prepare() called twice."); } catch (IOException ex) { logger.error("I/O error while performing prepare.", ex); throw new SimpleXAResourceException( "I/O error while performing prepare.", ex );
throw new SimpleXAResourceException("prepare() called twice."); } catch (IOException ex) { logger.error("I/O error while performing prepare.", ex); throw new SimpleXAResourceException( "I/O error while performing prepare.", ex );