/** {@inheritDoc} */ @Override public boolean equals(Object obj) { if (null == obj) { return false; } if (obj == this) { return true; } if (!getClass().equals(obj.getClass())) { return false; } final Fiji other = (Fiji) obj; // Equal if the two instances have the same URI: return mURI.equals(other.getURI()); }
/** {@inheritDoc} */ @Override public boolean equals(Object obj) { if (null == obj) { return false; } if (obj == this) { return true; } if (!getClass().equals(obj.getClass())) { return false; } final Fiji other = (Fiji) obj; // Equal if the two instances have the same URI: return mURI.equals(other.getURI()); }
/** * Lists all the tables in a fiji instance. * * @param fiji Fiji instance to list the tables of. * @return A program exit code (zero on success). * @throws IOException If there is an error. */ private int listTables(Fiji fiji) throws IOException { for (String name : fiji.getTableNames()) { getPrintStream().println(fiji.getURI() + name); } return SUCCESS; }
mFiji.getURI().getInstance()));
/** * Restores all tables from the metadata backup into the running Fiji instance. * * @param backup the deserialized backup of the metadata. * @param fiji the connected Fiji instance. * @throws IOException if there is an error communicating with HBase. */ public void restoreTables(MetadataBackup backup, Fiji fiji) throws IOException { final HBaseFactory hbaseFactory = HBaseFactory.Provider.get(); final HBaseAdmin hbaseAdmin = hbaseFactory.getHBaseAdminFactory(fiji.getURI()).create(fiji.getConf()); final FijiMetaTable metaTable = fiji.getMetaTable(); try { HBaseMetaTable.uninstall(hbaseAdmin, fiji.getURI()); HBaseMetaTable.install(hbaseAdmin, fiji.getURI()); final Map<String, TableBackup> tables = backup.getMetaTable().getTables(); for (Map.Entry<String, TableBackup> layoutEntry : tables.entrySet()) { final String tableName = layoutEntry.getKey(); LOG.debug("Found table backup entry for " + tableName); final TableBackup tableBackup = layoutEntry.getValue(); restoreTable(tableName, tableBackup, metaTable, fiji); } } finally { ResourceUtils.closeOrLog(hbaseAdmin); } }
/** * Deletes an entire Fiji instance. * * @param instanceURI The Fiji instance to delete. * @return tool exit code. * @throws Exception on error. */ private int deleteInstance(FijiURI instanceURI) throws Exception { final Fiji fiji = Fiji.Factory.open(instanceURI); try { getPrintStream().println("WARNING: This instance contains the table(s):"); for (String name : fiji.getTableNames()) { getPrintStream().println(name); } if (isInteractive() && !inputConfirmation( String.format("Are you sure you want to delete Fiji instance '%s'?", instanceURI), instanceURI.getInstance())) { getPrintStream().println("Delete aborted."); return FAILURE; } } finally { fiji.release(); } FijiInstaller.get().uninstall(fiji.getURI(), getConf()); getPrintStream().println(String.format("Fiji instance '%s' deleted.", fiji.getURI())); return SUCCESS; }
/** * Records information about a completed job into the history table of a Fiji instance. * * If the attempt fails due to an IOException (a Fiji cannot be made, there is no job history * table, its content is corrupted, etc.), we catch the exception and warn the user. * * @param fiji Fiji instance to write the job record to. * @throws IOException on I/O error. */ private void recordJobHistory(Fiji fiji) throws IOException { final Job job = getHadoopJob(); JobHistoryFijiTable jobHistory = null; try { jobHistory = JobHistoryFijiTable.open(fiji); jobHistory.recordJob(job, mJobStartTime, mJobEndTime); } catch (IOException ioe) { // We swallow errors for recording jobs, because it's a non-fatal error for the task. LOG.warn( "Error recording job {} in history table of Fiji instance {}:\n" + "{}\n" + "This does not affect the success of job {}.\n", getHadoopJob().getJobID(), fiji.getURI(), StringUtils.stringifyException(ioe), getHadoopJob().getJobID()); } finally { IOUtils.closeQuietly(jobHistory); } }