/** * Get {@link Storage} object corresponding to the name * * @param storageName The storage name * @return Returns storage if name passed is a storage * @throws LensException if there is no storage by the name */ public Storage getStorage(String storageName) throws LensException { return getStorage(storageName, true); }
public void updatePartitions(String factOrDimtableName, String storageName, Map<UpdatePeriod, List<Partition>> partitions) throws HiveException, InvalidOperationException, LensException { for (Map.Entry entry : partitions.entrySet()) { List<Partition> partitionsToAlter = Lists.newArrayList(); partitionsToAlter.addAll((List<Partition>) entry.getValue()); String storageTableName = getStorageTableName(factOrDimtableName, storageName, (UpdatePeriod) entry.getKey()); partitionsToAlter.addAll( getAllLatestPartsEquivalentTo(factOrDimtableName, storageTableName, (List<Partition>) entry.getValue())); getStorage(storageName).updatePartitions(storageTableName, getClient(), factOrDimtableName, partitionsToAlter); } }
getStorage(storageName).addPartitions(getClient(), factOrDimTable, updatePeriod, storagePartitionDescs, latestInfos, storageTableName); ListIterator<Partition> iter = partsAdded.listIterator(); partsAdded = getStorage(storageName).addPartitions(getClient(), factOrDimTable, updatePeriod, storagePartitionDescs, null, storageTableName);
/** * Get {@link Storage} object corresponding to the name * * @param storageName The storage name * @return Returns storage if name passed is a storage * @throws LensException if there is no storage by the name */ public Storage getStorage(String storageName) throws LensException { return getStorage(storageName, true); } public Storage getStorage(String storageName, boolean throwException) throws LensException {
public void updatePartitions(String factOrDimtableName, String storageName, Map<UpdatePeriod, List<Partition>> partitions) throws HiveException, InvalidOperationException, LensException { for (Map.Entry entry : partitions.entrySet()) { List<Partition> partitionsToAlter = Lists.newArrayList(); partitionsToAlter.addAll((List<Partition>) entry.getValue()); String storageTableName = getStorageTableName(factOrDimtableName, storageName, (UpdatePeriod) entry.getKey()); partitionsToAlter.addAll( getAllLatestPartsEquivalentTo(factOrDimtableName, storageTableName, (List<Partition>) entry.getValue())); getStorage(storageName).updatePartitions(storageTableName, getClient(), factOrDimtableName, partitionsToAlter); } }
getStorage(storageName).addPartitions(getClient(), factOrDimTable, updatePeriod, storagePartitionDescs, latestInfos, storageTableName); ListIterator<Partition> iter = partsAdded.listIterator(); partsAdded = getStorage(storageName).addPartitions(getClient(), factOrDimTable, updatePeriod, storagePartitionDescs, null, storageTableName);
public Storage getStorage(String storageName, boolean throwException) throws LensException { storageName = storageName.trim().toLowerCase(); Storage storage = allStorages.get(storageName); if (storage == null) { synchronized (allStorages) { if (!allStorages.containsKey(storageName)) { Table tbl = getTableWithType(storageName, CubeTableType.STORAGE, throwException); if (tbl != null) { storage = getStorage(tbl); if (enableCaching && storage != null) { allStorages.put(storageName, storage); } } } else { storage = allStorages.get(storageName); } } } return storage; }
getStorage(storageName).dropPartition(getClient(), storageTableName, partVals, latest, nonTimePartSpec); if (!latestAvailable) { getStorage(storageName).dropPartition(getClient(), storageTableName, partVals, null, null); if (partitionTimelineCache.updateForDeletion(cubeTableName, storageName, updatePeriod, timePartSpec)) { this.alterTablePartitionCache((Storage.getPrefix(storageName) + cubeTableName).toLowerCase(), updatePeriod,
public Storage getStorage(String storageName, boolean throwException) throws LensException { storageName = storageName.trim().toLowerCase(); Storage storage = allStorages.get(storageName); if (storage == null) { synchronized (allStorages) { if (!allStorages.containsKey(storageName)) { Table tbl = getTableWithType(storageName, CubeTableType.STORAGE, throwException); if (tbl != null) { storage = getStorage(tbl); if (enableCaching && storage != null) { allStorages.put(storageName, storage); } } } else { storage = allStorages.get(storageName); } } } return storage; }
getStorage(storageName).dropPartition(getClient(), storageTableName, partVals, latest, nonTimePartSpec); if (!latestAvailable) { getStorage(storageName).dropPartition(getClient(), storageTableName, partVals, null, null); if (partitionTimelineCache.updateForDeletion(cubeTableName, storageName, updatePeriod, timePartSpec)) { this.alterTablePartitionCache((Storage.getPrefix(storageName) + cubeTableName).toLowerCase(), updatePeriod,
public void alterStorage(String storageName, Storage storage) throws LensException, HiveException { Table storageTbl = getTableWithTypeFailFast(storageName, CubeTableType.STORAGE); alterCubeTable(storageName, storageTbl, storage); if (enableCaching) { allStorages.put(storageName.trim().toLowerCase(), getStorage(refreshTable(storageName))); } }
public void createStorage(Storage storage) throws LensException { createCubeHiveTable(storage); // do a get to update cache getStorage(storage.getName()); }
/** * Get all storages in metastore * * @return List of Storage objects * @throws LensException */ public Collection<Storage> getAllStorages() throws LensException { if (!allStoragesPopulated) { List<Storage> storages = new ArrayList<>(); try { for (String table : getAllHiveTableNames()) { Storage storage = getStorage(table, false); if (storage != null) { storages.add(storage); } } } catch (HiveException e) { throw new LensException("Could not get all storages", e); } allStoragesPopulated = enableCaching; return storages; } else { return allStorages.values(); } }
public void alterStorage(String storageName, Storage storage) throws LensException, HiveException { checkIfAuthorized(); Table storageTbl = getTableWithTypeFailFast(storageName, CubeTableType.STORAGE); alterCubeTable(storageName, storageTbl, storage); if (enableCaching) { allStorages.put(storageName.trim().toLowerCase(), getStorage(refreshTable(storageName))); } }
/** * Get all storages in metastore * * @return List of Storage objects * @throws LensException */ public Collection<Storage> getAllStorages() throws LensException { if (!allStoragesPopulated) { List<Storage> storages = new ArrayList<>(); try { for (String table : getAllHiveTableNames()) { Storage storage = getStorage(table, false); if (storage != null) { storages.add(storage); } } } catch (HiveException e) { throw new LensException("Could not get all storages", e); } allStoragesPopulated = enableCaching; return storages; } else { return allStorages.values(); } }
public void createStorage(Storage storage) throws LensException { checkIfAuthorized(); createCubeHiveTable(storage); // do a get to update cache getStorage(storage.getName()); }
@Override public XStorage getStorage(LensSessionHandle sessionid, String storageName) throws LensException { try (SessionContext ignored = new SessionContext(sessionid)){ return JAXBUtils.xstorageFromStorage(getClient(sessionid).getStorage(storageName)); } }
@Test(priority = 1) public void testStorage() throws Exception { Storage hdfsStorage = new HDFSStorage(c1); client.createStorage(hdfsStorage); assertEquals(client.getAllStorages().size(), 1); Storage hdfsStorage2 = new HDFSStorage(c2); client.createStorage(hdfsStorage2); assertEquals(client.getAllStorages().size(), 2); Storage hdfsStorage3 = new HDFSStorage(c3); client.createStorage(hdfsStorage3); assertEquals(client.getAllStorages().size(), 3); Storage hdfsStorage4 = new HDFSStorage(c4); client.createStorage(hdfsStorage4); assertEquals(client.getAllStorages().size(), 4); assertEquals(hdfsStorage, client.getStorage(c1)); assertEquals(hdfsStorage2, client.getStorage(c2)); assertEquals(hdfsStorage3, client.getStorage(c3)); assertEquals(hdfsStorage4, client.getStorage(c4)); }