@Test public void testGetTableSnapshots() throws IOException { TableSignature tableSignature = new TableSignature("TEST_CAL_DT.csv", 100, System.currentTimeMillis()); List<TableSnapshotResponse> snapshotResponseList = tableService.internalGetLookupTableSnapshots("EDW.TEST_CAL_DT", tableSignature); Assert.assertEquals(8, snapshotResponseList.size()); }
List<TableSnapshotResponse> internalGetLookupTableSnapshots(String tableName, TableSignature signature) throws IOException { ExtTableSnapshotInfoManager extSnapshotInfoManager = ExtTableSnapshotInfoManager.getInstance(getConfig()); SnapshotManager snapshotManager = SnapshotManager.getInstance(getConfig()); List<ExtTableSnapshotInfo> extTableSnapshots = extSnapshotInfoManager.getSnapshots(tableName); List<SnapshotTable> metaStoreTableSnapshots = snapshotManager.getSnapshots(tableName, signature); Map<String, List<String>> snapshotUsageMap = getSnapshotUsages(); List<TableSnapshotResponse> result = Lists.newArrayList(); for (ExtTableSnapshotInfo extTableSnapshot : extTableSnapshots) { TableSnapshotResponse response = new TableSnapshotResponse(); response.setSnapshotID(extTableSnapshot.getId()); response.setSnapshotType(TableSnapshotResponse.TYPE_EXT); response.setLastBuildTime(extTableSnapshot.getLastBuildTime()); response.setStorageType(extTableSnapshot.getStorageType()); response.setSourceTableSize(extTableSnapshot.getSignature().getSize()); response.setSourceTableLastModifyTime(extTableSnapshot.getSignature().getLastModifiedTime()); response.setCubesAndSegmentsUsage(snapshotUsageMap.get(extTableSnapshot.getResourcePath())); result.add(response); } for (SnapshotTable metaStoreTableSnapshot : metaStoreTableSnapshots) { TableSnapshotResponse response = new TableSnapshotResponse(); response.setSnapshotID(metaStoreTableSnapshot.getId()); response.setSnapshotType(TableSnapshotResponse.TYPE_INNER); response.setLastBuildTime(metaStoreTableSnapshot.getLastBuildTime()); response.setStorageType(SnapshotTable.STORAGE_TYPE_METASTORE); response.setSourceTableSize(metaStoreTableSnapshot.getSignature().getSize()); response.setSourceTableLastModifyTime(metaStoreTableSnapshot.getSignature().getLastModifiedTime()); response.setCubesAndSegmentsUsage(snapshotUsageMap.get(metaStoreTableSnapshot.getResourcePath())); result.add(response); } return result; }
TableService extends BasicService { List<TableSnapshotResponse> internalGetLookupTableSnapshots(String tableName, TableSignature signature) throws IOException { ExtTableSnapshotInfoManager extSnapshotInfoManager = ExtTableSnapshotInfoManager.getInstance(getConfig()); SnapshotManager snapshotManager = SnapshotManager.getInstance(getConfig()); List<ExtTableSnapshotInfo> extTableSnapshots = extSnapshotInfoManager.getSnapshots(tableName); List<SnapshotTable> metaStoreTableSnapshots = snapshotManager.getSnapshots(tableName, signature); Map<String, List<String>> snapshotUsageMap = getSnapshotUsages(); List<TableSnapshotResponse> result = Lists.newArrayList(); for (ExtTableSnapshotInfo extTableSnapshot : extTableSnapshots) { TableSnapshotResponse response = new TableSnapshotResponse(); response.setSnapshotID(extTableSnapshot.getId()); response.setSnapshotType(TableSnapshotResponse.TYPE_EXT); response.setLastBuildTime(extTableSnapshot.getLastBuildTime()); response.setStorageType(extTableSnapshot.getStorageType()); response.setSourceTableSize(extTableSnapshot.getSignature().getSize()); response.setSourceTableLastModifyTime(extTableSnapshot.getSignature().getLastModifiedTime()); response.setCubesAndSegmentsUsage(snapshotUsageMap.get(extTableSnapshot.getResourcePath())); result.add(response); } for (SnapshotTable metaStoreTableSnapshot : metaStoreTableSnapshots) { TableSnapshotResponse response = new TableSnapshotResponse(); response.setSnapshotID(metaStoreTableSnapshot.getId()); response.setSnapshotType(TableSnapshotResponse.TYPE_INNER); response.setLastBuildTime(metaStoreTableSnapshot.getLastBuildTime()); response.setStorageType(SnapshotTable.STORAGE_TYPE_METASTORE); response.setSourceTableSize(metaStoreTableSnapshot.getSignature().getSize()); response.setSourceTableLastModifyTime(metaStoreTableSnapshot.getSignature().getLastModifiedTime()); response.setCubesAndSegmentsUsage(snapshotUsageMap.get(metaStoreTableSnapshot.getResourcePath())); result.add(response); } return result; } }
TableService extends BasicService { List<TableSnapshotResponse> internalGetLookupTableSnapshots(String tableName, TableSignature signature) throws IOException { ExtTableSnapshotInfoManager extSnapshotInfoManager = ExtTableSnapshotInfoManager.getInstance(getConfig()); SnapshotManager snapshotManager = SnapshotManager.getInstance(getConfig()); List<ExtTableSnapshotInfo> extTableSnapshots = extSnapshotInfoManager.getSnapshots(tableName); List<SnapshotTable> metaStoreTableSnapshots = snapshotManager.getSnapshots(tableName, signature); Map<String, List<String>> snapshotUsageMap = getSnapshotUsages(); List<TableSnapshotResponse> result = Lists.newArrayList(); for (ExtTableSnapshotInfo extTableSnapshot : extTableSnapshots) { TableSnapshotResponse response = new TableSnapshotResponse(); response.setSnapshotID(extTableSnapshot.getId()); response.setSnapshotType(TableSnapshotResponse.TYPE_EXT); response.setLastBuildTime(extTableSnapshot.getLastBuildTime()); response.setStorageType(extTableSnapshot.getStorageType()); response.setSourceTableSize(extTableSnapshot.getSignature().getSize()); response.setSourceTableLastModifyTime(extTableSnapshot.getSignature().getLastModifiedTime()); response.setCubesAndSegmentsUsage(snapshotUsageMap.get(extTableSnapshot.getResourcePath())); result.add(response); } for (SnapshotTable metaStoreTableSnapshot : metaStoreTableSnapshots) { TableSnapshotResponse response = new TableSnapshotResponse(); response.setSnapshotID(metaStoreTableSnapshot.getId()); response.setSnapshotType(TableSnapshotResponse.TYPE_INNER); response.setLastBuildTime(metaStoreTableSnapshot.getLastBuildTime()); response.setStorageType(SnapshotTable.STORAGE_TYPE_METASTORE); response.setSourceTableSize(metaStoreTableSnapshot.getSignature().getSize()); response.setSourceTableLastModifyTime(metaStoreTableSnapshot.getSignature().getLastModifiedTime()); response.setCubesAndSegmentsUsage(snapshotUsageMap.get(metaStoreTableSnapshot.getResourcePath())); result.add(response); } return result; }  }
TableService extends BasicService { List<TableSnapshotResponse> internalGetLookupTableSnapshots(String tableName, TableSignature signature) throws IOException { ExtTableSnapshotInfoManager extSnapshotInfoManager = ExtTableSnapshotInfoManager.getInstance(getConfig()); SnapshotManager snapshotManager = SnapshotManager.getInstance(getConfig()); List<ExtTableSnapshotInfo> extTableSnapshots = extSnapshotInfoManager.getSnapshots(tableName); List<SnapshotTable> metaStoreTableSnapshots = snapshotManager.getSnapshots(tableName, signature); Map<String, List<String>> snapshotUsageMap = getSnapshotUsages(); List<TableSnapshotResponse> result = Lists.newArrayList(); for (ExtTableSnapshotInfo extTableSnapshot : extTableSnapshots) { TableSnapshotResponse response = new TableSnapshotResponse(); response.setSnapshotID(extTableSnapshot.getId()); response.setSnapshotType(TableSnapshotResponse.TYPE_EXT); response.setLastBuildTime(extTableSnapshot.getLastBuildTime()); response.setStorageType(extTableSnapshot.getStorageType()); response.setSourceTableSize(extTableSnapshot.getSignature().getSize()); response.setSourceTableLastModifyTime(extTableSnapshot.getSignature().getLastModifiedTime()); response.setCubesAndSegmentsUsage(snapshotUsageMap.get(extTableSnapshot.getResourcePath())); result.add(response); } for (SnapshotTable metaStoreTableSnapshot : metaStoreTableSnapshots) { TableSnapshotResponse response = new TableSnapshotResponse(); response.setSnapshotID(metaStoreTableSnapshot.getId()); response.setSnapshotType(TableSnapshotResponse.TYPE_INNER); response.setLastBuildTime(metaStoreTableSnapshot.getLastBuildTime()); response.setStorageType(SnapshotTable.STORAGE_TYPE_METASTORE); response.setSourceTableSize(metaStoreTableSnapshot.getSignature().getSize()); response.setSourceTableLastModifyTime(metaStoreTableSnapshot.getSignature().getLastModifiedTime()); response.setCubesAndSegmentsUsage(snapshotUsageMap.get(metaStoreTableSnapshot.getResourcePath())); result.add(response); } return result; }  List<TableDesc> getTableDescByProject(String project, boolean withExt); TableDesc getTableDescByName(String tableName, boolean withExt, String prj); String[] loadHiveTablesToProject(String[] hiveTables, String project); String[] loadTableToProject(TableDesc tableDesc, TableExtDesc extDesc, String project); List<Pair<TableDesc, TableExtDesc>> extractHiveTableMeta(String[] tables, String project); boolean unloadHiveTable(String tableName, String project); List<String> getSourceDbNames(String project); List<String> getSourceTableNames(String project, String database); void calculateCardinalityIfNotPresent(String[] tables, String submitter, String prj); void updateSnapshotLocalCache(String project, String tableName, String snapshotID); void removeSnapshotLocalCache(String tableName, String snapshotID); String getSnapshotLocalCacheState(String tableName, String snapshotID); List<TableSnapshotResponse> getLookupTableSnapshots(String project, String tableName); void calculateCardinality(String tableName, String submitter, String prj); String normalizeHiveTableName(String tableName); List<CsvColumnDesc> parseCsvFile(MultipartFile file, boolean withHeader, String separator); TableDesc generateCsvTableDesc(String tableName, List<String> columnDescList); TableExtDesc generateTableExtDesc(TableDesc tableDesc, boolean withHeader, String separator); void saveCsvFile(MultipartFile file, String tableName, String project); }
TableService extends BasicService { List<TableSnapshotResponse> internalGetLookupTableSnapshots(String tableName, TableSignature signature) throws IOException { ExtTableSnapshotInfoManager extSnapshotInfoManager = ExtTableSnapshotInfoManager.getInstance(getConfig()); SnapshotManager snapshotManager = SnapshotManager.getInstance(getConfig()); List<ExtTableSnapshotInfo> extTableSnapshots = extSnapshotInfoManager.getSnapshots(tableName); List<SnapshotTable> metaStoreTableSnapshots = snapshotManager.getSnapshots(tableName, signature); Map<String, List<String>> snapshotUsageMap = getSnapshotUsages(); List<TableSnapshotResponse> result = Lists.newArrayList(); for (ExtTableSnapshotInfo extTableSnapshot : extTableSnapshots) { TableSnapshotResponse response = new TableSnapshotResponse(); response.setSnapshotID(extTableSnapshot.getId()); response.setSnapshotType(TableSnapshotResponse.TYPE_EXT); response.setLastBuildTime(extTableSnapshot.getLastBuildTime()); response.setStorageType(extTableSnapshot.getStorageType()); response.setSourceTableSize(extTableSnapshot.getSignature().getSize()); response.setSourceTableLastModifyTime(extTableSnapshot.getSignature().getLastModifiedTime()); response.setCubesAndSegmentsUsage(snapshotUsageMap.get(extTableSnapshot.getResourcePath())); result.add(response); } for (SnapshotTable metaStoreTableSnapshot : metaStoreTableSnapshots) { TableSnapshotResponse response = new TableSnapshotResponse(); response.setSnapshotID(metaStoreTableSnapshot.getId()); response.setSnapshotType(TableSnapshotResponse.TYPE_INNER); response.setLastBuildTime(metaStoreTableSnapshot.getLastBuildTime()); response.setStorageType(SnapshotTable.STORAGE_TYPE_METASTORE); response.setSourceTableSize(metaStoreTableSnapshot.getSignature().getSize()); response.setSourceTableLastModifyTime(metaStoreTableSnapshot.getSignature().getLastModifiedTime()); response.setCubesAndSegmentsUsage(snapshotUsageMap.get(metaStoreTableSnapshot.getResourcePath())); result.add(response); } return result; }  List<TableDesc> getTableDescByProject(String project, boolean withExt); TableDesc getTableDescByName(String tableName, boolean withExt, String prj); String[] loadHiveTablesToProject(String[] hiveTables, String project); String[] loadTableToProject(TableDesc tableDesc, TableExtDesc extDesc, String project); List<Pair<TableDesc, TableExtDesc>> extractHiveTableMeta(String[] tables, String project); boolean unloadHiveTable(String tableName, String project); List<String> getSourceDbNames(String project); List<String> getSourceTableNames(String project, String database); void calculateCardinalityIfNotPresent(String[] tables, String submitter, String prj); void updateSnapshotLocalCache(String project, String tableName, String snapshotID); void removeSnapshotLocalCache(String tableName, String snapshotID); String getSnapshotLocalCacheState(String tableName, String snapshotID); List<TableSnapshotResponse> getLookupTableSnapshots(String project, String tableName); void calculateCardinality(String tableName, String submitter, String prj); String normalizeHiveTableName(String tableName); List<CsvColumnDesc> parseCsvFile(MultipartFile file, boolean withHeader, String separator); TableDesc generateCsvTableDesc(String tableName, List<String> columnDescList); TableExtDesc generateTableExtDesc(TableDesc tableDesc, boolean withHeader, String separator); void saveCsvFile(MultipartFile file, String tableName, String project);  }