Path p = writeTableDescriptor(fs, htd, tableDir, status); return p != null;
/** * Update table descriptor on the file system * @throws IOException Thrown if failed update. * @throws NotImplementedException if in read only mode */ @VisibleForTesting Path updateTableDescriptor(TableDescriptor td) throws IOException { if (fsreadonly) { throw new NotImplementedException("Cannot update a table descriptor - in read only mode"); } TableName tableName = td.getTableName(); Path tableDir = getTableDir(tableName); Path p = writeTableDescriptor(fs, td, tableDir, getTableInfoPath(tableDir)); if (p == null) throw new IOException("Failed update"); LOG.info("Updated tableinfo=" + p); if (usecache) { this.cache.put(td.getTableName(), td); } return p; }
private static void rewriteTableDescriptor(final FileSystem fs, final FileStatus status, final HTableDescriptor td) throws IOException { Path tableInfoDir = status.getPath().getParent(); Path tableDir = tableInfoDir.getParent(); writeTableDescriptor(fs, td, tableDir, status); }
/** * Create a new HTableDescriptor in HDFS in the specified table directory. Happens when we create * a new table or snapshot a table. * @param fs filesystem where the descriptor should be written * @param tabledir directory under which we should write the file * @param htableDescriptor description of the table to write * @param forceCreation if <tt>true</tt>,then even if previous table descriptor is present it will * be overwritten * @return <tt>true</tt> if the we successfully created the file, <tt>false</tt> if the file * already exists and we weren't forcing the descriptor creation. * @throws IOException if a filesystem error occurs */ public static boolean createTableDescriptorForTableDirectory(FileSystem fs, Path tabledir, HTableDescriptor htableDescriptor, boolean forceCreation) throws IOException { FileStatus status = getTableInfoPath(fs, tabledir); if (status != null) { LOG.info("Current tableInfoPath = " + status.getPath()); if (!forceCreation) { if (fs.exists(status.getPath()) && status.getLen() > 0) { LOG.info("TableInfo already exists.. Skipping creation"); return false; } } } Path p = writeTableDescriptor(fs, htableDescriptor, tabledir, status); return p != null; } }
/** * Update table descriptor * @param fs * @param conf * @param hTableDescriptor * @return New tableinfo or null if we failed update. * @throws IOException Thrown if failed update. */ static Path updateHTableDescriptor(FileSystem fs, Path rootdir, HTableDescriptor hTableDescriptor) throws IOException { Path tableDir = FSUtils.getTablePath(rootdir, hTableDescriptor.getName()); Path p = writeTableDescriptor(fs, hTableDescriptor, tableDir, getTableInfoPath(fs, tableDir)); if (p == null) throw new IOException("Failed update"); LOG.info("Updated tableinfo=" + p); return p; }
Path p = writeTableDescriptor(fs, htd, tableDir, status); return p != null;
/** * Update table descriptor on the file system * @throws IOException Thrown if failed update. * @throws NotImplementedException if in read only mode */ @VisibleForTesting Path updateTableDescriptor(HTableDescriptor htd) throws IOException { if (fsreadonly) { throw new NotImplementedException("Cannot update a table descriptor - in read only mode"); } Path tableDir = getTableDir(htd.getTableName()); Path p = writeTableDescriptor(fs, htd, tableDir, getTableInfoPath(tableDir)); if (p == null) throw new IOException("Failed update"); LOG.info("Updated tableinfo=" + p); if (usecache) { this.cache.put(htd.getTableName(), htd); } return p; }