@Test public void getErrorCasesTest() throws StoreException { List<StoreKey> listWithDups = new ArrayList<>(); listWithDups.add(liveKeys.iterator().next()); listWithDups.add(listWithDups.get(0)); try { store.get(listWithDups, EnumSet.noneOf(StoreGetOptions.class)); fail("GET of " + listWithDups + " should have failed"); } catch (IllegalArgumentException e) { } }
@Override public StoreInfo get(List<? extends StoreKey> ids, EnumSet<StoreGetOptions> storeGetOptions) throws StoreException { checkStarted(); final Timer.Context context = metrics.getResponse.time(); if (ids.size() > 1 && ids.size() != new HashSet<>(ids).size()) { metrics.duplicateKeysInBatch.inc(); throw new IllegalArgumentException("The list of IDs provided contains duplicates"); } try { List<BlobReadOptions> readOptions = new ArrayList<BlobReadOptions>(ids.size()); Map<StoreKey, MessageInfo> indexMessages = new HashMap<StoreKey, MessageInfo>(ids.size()); for (StoreKey key : ids) { BlobReadOptions readInfo = index.getBlobReadInfo(key, storeGetOptions); readOptions.add(readInfo); indexMessages.put(key, readInfo.getMessageInfo()); if (!key.isAccountContainerMatch(readInfo.getMessageInfo().getAccountId(), readInfo.getMessageInfo().getContainerId())) { if (config.storeValidateAuthorization) { throw new StoreException( "GET authorization failure. Key: " + key.getID() + " Actually accountId: " + readInfo.getMessageInfo() .getAccountId() + " Actually containerId: " + readInfo.getMessageInfo().getContainerId(), StoreErrorCodes.Authorization_Failure); } else { logger.warn("GET authorization failure. Key: {} Actually accountId: {} Actually containerId: {}", key.getID(), readInfo.getMessageInfo().getAccountId(), readInfo.getMessageInfo().getContainerId()); metrics.getAuthorizationFailureCount.inc(); } } } MessageReadSet readSet = new StoreMessageReadSet(readOptions); List<MessageInfo> messageInfoList = new ArrayList<MessageInfo>(readSet.count()); for (int i = 0; i < readSet.count(); i++) { messageInfoList.add(indexMessages.get(readSet.getKeyAt(i))); } onSuccess(); return new StoreInfo(readSet, messageInfoList); } catch (StoreException e) { if (e.getErrorCode() == StoreErrorCodes.IOError) { onError(); } throw e; } catch (Exception e) { throw new StoreException("Unknown exception while trying to fetch blobs from store " + dataDir, e, StoreErrorCodes.Unknown_Error); } finally { context.stop(); } }
BlobStore implements Store { @Override public StoreInfo get(List<? extends StoreKey> ids, EnumSet<StoreGetOptions> storeGetOptions) throws StoreException { checkStarted(); final Timer.Context context = metrics.getResponse.time(); if (ids.size() > 1 && ids.size() != new HashSet<>(ids).size()) { metrics.duplicateKeysInBatch.inc(); throw new IllegalArgumentException("The list of IDs provided contains duplicates"); } try { List<BlobReadOptions> readOptions = new ArrayList<BlobReadOptions>(ids.size()); Map<StoreKey, MessageInfo> indexMessages = new HashMap<StoreKey, MessageInfo>(ids.size()); for (StoreKey key : ids) { BlobReadOptions readInfo = index.getBlobReadInfo(key, storeGetOptions); readOptions.add(readInfo); indexMessages.put(key, readInfo.getMessageInfo()); if (!key.isAccountContainerMatch(readInfo.getMessageInfo().getAccountId(), readInfo.getMessageInfo().getContainerId())) { if (config.storeValidateAuthorization) { throw new StoreException( "GET authorization failure. Key: " + key.getID() + " Actually accountId: " + readInfo.getMessageInfo() .getAccountId() + " Actually containerId: " + readInfo.getMessageInfo().getContainerId(), StoreErrorCodes.Authorization_Failure); } else { logger.warn("GET authorization failure. Key: {} Actually accountId: {} Actually containerId: {}", key.getID(), readInfo.getMessageInfo().getAccountId(), readInfo.getMessageInfo().getContainerId()); metrics.getAuthorizationFailureCount.inc(); } } } MessageReadSet readSet = new StoreMessageReadSet(readOptions); List<MessageInfo> messageInfoList = new ArrayList<MessageInfo>(readSet.count()); for (int i = 0; i < readSet.count(); i++) { messageInfoList.add(indexMessages.get(readSet.getKeyAt(i))); } onSuccess(); return new StoreInfo(readSet, messageInfoList); } catch (StoreException e) { if (e.getErrorCode() == StoreErrorCodes.IOError) { onError(); } throw e; } catch (Exception e) { throw new StoreException("Unknown exception while trying to fetch blobs from store " + dataDir, e, StoreErrorCodes.Unknown_Error); } finally { context.stop(); } } }
BlobStore implements Store { @Override public StoreInfo get(List<? extends StoreKey> ids, EnumSet<StoreGetOptions> storeGetOptions) throws StoreException { checkStarted(); final Timer.Context context = metrics.getResponse.time(); if (ids.size() > 1 && ids.size() != new HashSet<>(ids).size()) { metrics.duplicateKeysInBatch.inc(); throw new IllegalArgumentException("The list of IDs provided contains duplicates"); } try { List<BlobReadOptions> readOptions = new ArrayList<BlobReadOptions>(ids.size()); Map<StoreKey, MessageInfo> indexMessages = new HashMap<StoreKey, MessageInfo>(ids.size()); for (StoreKey key : ids) { BlobReadOptions readInfo = index.getBlobReadInfo(key, storeGetOptions); readOptions.add(readInfo); indexMessages.put(key, readInfo.getMessageInfo()); if (!key.isAccountContainerMatch(readInfo.getMessageInfo().getAccountId(), readInfo.getMessageInfo().getContainerId())) { if (config.storeValidateAuthorization) { throw new StoreException( "GET authorization failure. Key: " + key.getID() + " Actually accountId: " + readInfo.getMessageInfo() .getAccountId() + " Actually containerId: " + readInfo.getMessageInfo().getContainerId(), StoreErrorCodes.Authorization_Failure); } else { logger.warn("GET authorization failure. Key: {} Actually accountId: {} Actually containerId: {}", key.getID(), readInfo.getMessageInfo().getAccountId(), readInfo.getMessageInfo().getContainerId()); metrics.getAuthorizationFailureCount.inc(); } } } MessageReadSet readSet = new StoreMessageReadSet(readOptions); List<MessageInfo> messageInfoList = new ArrayList<MessageInfo>(readSet.count()); for (int i = 0; i < readSet.count(); i++) { messageInfoList.add(indexMessages.get(readSet.getKeyAt(i))); } onSuccess(); return new StoreInfo(readSet, messageInfoList); } catch (StoreException e) { if (e.getErrorCode() == StoreErrorCodes.IOError) { onError(); } throw e; } catch (Exception e) { throw new StoreException("Unknown exception while trying to fetch blobs from store " + dataDir, e, StoreErrorCodes.Unknown_Error); } finally { context.stop(); } } BlobStore(ReplicaId replicaId, StoreConfig config, ScheduledExecutorService taskScheduler,
      ScheduledExecutorService longLivedTaskScheduler, DiskIOScheduler diskIOScheduler,
      DiskSpaceAllocator diskSpaceAllocator, StoreMetrics metrics, StoreMetrics storeUnderCompactionMetrics,
      StoreKeyFactory factory, MessageStoreRecovery recovery, MessageStoreHardDelete hardDelete,
      List<ReplicaStatusDelegate> replicaStatusDelegates, Time time, AccountService accountService);   BlobStore(String storeId, StoreConfig config, ScheduledExecutorService taskScheduler,
      ScheduledExecutorService longLivedTaskScheduler, DiskIOScheduler diskIOScheduler,
      DiskSpaceAllocator diskSpaceAllocator, StoreMetrics metrics, StoreMetrics storeUnderCompactionMetrics,
      String dataDir, long capacityInBytes, StoreKeyFactory factory, MessageStoreRecovery recovery,
      MessageStoreHardDelete hardDelete, Time time);   BlobStore(ReplicaId replicaId, String storeId, StoreConfig config, ScheduledExecutorService taskScheduler,
      ScheduledExecutorService longLivedTaskScheduler, DiskIOScheduler diskIOScheduler,
      DiskSpaceAllocator diskSpaceAllocator, StoreMetrics metrics, StoreMetrics storeUnderCompactionMetrics,
      String dataDir, long capacityInBytes, StoreKeyFactory factory, MessageStoreRecovery recovery,
      MessageStoreHardDelete hardDelete, List<ReplicaStatusDelegate> replicaStatusDelegates, Time time,
      AccountService accountService, BlobStoreStats blobStoreStats); }
BlobStore implements Store { @Override public StoreInfo get(List<? extends StoreKey> ids, EnumSet<StoreGetOptions> storeGetOptions) throws StoreException { checkStarted(); final Timer.Context context = metrics.getResponse.time(); if (ids.size() > 1 && ids.size() != new HashSet<>(ids).size()) { metrics.duplicateKeysInBatch.inc(); throw new IllegalArgumentException("The list of IDs provided contains duplicates"); } try { List<BlobReadOptions> readOptions = new ArrayList<BlobReadOptions>(ids.size()); Map<StoreKey, MessageInfo> indexMessages = new HashMap<StoreKey, MessageInfo>(ids.size()); for (StoreKey key : ids) { BlobReadOptions readInfo = index.getBlobReadInfo(key, storeGetOptions); readOptions.add(readInfo); indexMessages.put(key, readInfo.getMessageInfo()); if (!key.isAccountContainerMatch(readInfo.getMessageInfo().getAccountId(), readInfo.getMessageInfo().getContainerId())) { if (config.storeValidateAuthorization) { throw new StoreException( "GET authorization failure. Key: " + key.getID() + " Actually accountId: " + readInfo.getMessageInfo() .getAccountId() + " Actually containerId: " + readInfo.getMessageInfo().getContainerId(), StoreErrorCodes.Authorization_Failure); } else { logger.warn("GET authorization failure. Key: {} Actually accountId: {} Actually containerId: {}", key.getID(), readInfo.getMessageInfo().getAccountId(), readInfo.getMessageInfo().getContainerId()); metrics.getAuthorizationFailureCount.inc(); } } } MessageReadSet readSet = new StoreMessageReadSet(readOptions); List<MessageInfo> messageInfoList = new ArrayList<MessageInfo>(readSet.count()); for (int i = 0; i < readSet.count(); i++) { messageInfoList.add(indexMessages.get(readSet.getKeyAt(i))); } onSuccess(); return new StoreInfo(readSet, messageInfoList); } catch (StoreException e) { if (e.getErrorCode() == StoreErrorCodes.IOError) { onError(); } throw e; } catch (Exception e) { throw new StoreException("Unknown exception while trying to fetch blobs from store " + dataDir, e, StoreErrorCodes.Unknown_Error); } finally { context.stop(); } } BlobStore(ReplicaId replicaId, StoreConfig config, ScheduledExecutorService taskScheduler,
      ScheduledExecutorService longLivedTaskScheduler, DiskIOScheduler diskIOScheduler,
      DiskSpaceAllocator diskSpaceAllocator, StoreMetrics metrics, StoreMetrics storeUnderCompactionMetrics,
      StoreKeyFactory factory, MessageStoreRecovery recovery, MessageStoreHardDelete hardDelete,
      List<ReplicaStatusDelegate> replicaStatusDelegates, Time time, AccountService accountService);   BlobStore(String storeId, StoreConfig config, ScheduledExecutorService taskScheduler,
      ScheduledExecutorService longLivedTaskScheduler, DiskIOScheduler diskIOScheduler,
      DiskSpaceAllocator diskSpaceAllocator, StoreMetrics metrics, StoreMetrics storeUnderCompactionMetrics,
      String dataDir, long capacityInBytes, StoreKeyFactory factory, MessageStoreRecovery recovery,
      MessageStoreHardDelete hardDelete, Time time);   BlobStore(ReplicaId replicaId, String storeId, StoreConfig config, ScheduledExecutorService taskScheduler,
      ScheduledExecutorService longLivedTaskScheduler, DiskIOScheduler diskIOScheduler,
      DiskSpaceAllocator diskSpaceAllocator, StoreMetrics metrics, StoreMetrics storeUnderCompactionMetrics,
      String dataDir, long capacityInBytes, StoreKeyFactory factory, MessageStoreRecovery recovery,
      MessageStoreHardDelete hardDelete, List<ReplicaStatusDelegate> replicaStatusDelegates, Time time,
      AccountService accountService, BlobStoreStats blobStoreStats); @Override void start(); @Override StoreInfo get(List<? extends StoreKey> ids, EnumSet<StoreGetOptions> storeGetOptions); @Override void put(MessageWriteSet messageSetToWrite); @Override void delete(List<MessageInfo> infosToDelete); @Override void updateTtl(List<MessageInfo> infosToUpdate); @Override short undelete(MessageInfo info); @Override FindInfo findEntriesSince(FindToken token, long maxTotalSizeOfEntries); @Override Set<StoreKey> findMissingKeys(List<StoreKey> keys); @Override MessageInfo findKey(StoreKey key); @Override StoreStats getStoreStats(); @Override boolean isKeyDeleted(StoreKey key); @Override long getSizeInBytes(); long getLogEndOffsetInBytes(); @Override boolean isEmpty(); @Override boolean isBootstrapInProgress(); @Override boolean isDecommissionInProgress(); @Override void completeBootstrap(); @Override void setCurrentState(ReplicaState state); @Override ReplicaState getCurrentState(); @Override boolean recoverFromDecommission(); @Override boolean disabledOnError(); void deleteStoreFiles(); @Override long getEndPositionOfLastPut(); List<ReplicaStatusDelegate> getReplicaStatusDelegates(); @Override void shutdown(); @Override boolean isStarted(); @Override String toString(); }
BlobStore implements Store { @Override public StoreInfo get(List<? extends StoreKey> ids, EnumSet<StoreGetOptions> storeGetOptions) throws StoreException { checkStarted(); final Timer.Context context = metrics.getResponse.time(); if (ids.size() > 1 && ids.size() != new HashSet<>(ids).size()) { metrics.duplicateKeysInBatch.inc(); throw new IllegalArgumentException("The list of IDs provided contains duplicates"); } try { List<BlobReadOptions> readOptions = new ArrayList<BlobReadOptions>(ids.size()); Map<StoreKey, MessageInfo> indexMessages = new HashMap<StoreKey, MessageInfo>(ids.size()); for (StoreKey key : ids) { BlobReadOptions readInfo = index.getBlobReadInfo(key, storeGetOptions); readOptions.add(readInfo); indexMessages.put(key, readInfo.getMessageInfo()); if (!key.isAccountContainerMatch(readInfo.getMessageInfo().getAccountId(), readInfo.getMessageInfo().getContainerId())) { if (config.storeValidateAuthorization) { throw new StoreException( "GET authorization failure. Key: " + key.getID() + " Actually accountId: " + readInfo.getMessageInfo() .getAccountId() + " Actually containerId: " + readInfo.getMessageInfo().getContainerId(), StoreErrorCodes.Authorization_Failure); } else { logger.warn("GET authorization failure. Key: {} Actually accountId: {} Actually containerId: {}", key.getID(), readInfo.getMessageInfo().getAccountId(), readInfo.getMessageInfo().getContainerId()); metrics.getAuthorizationFailureCount.inc(); } } } MessageReadSet readSet = new StoreMessageReadSet(readOptions); List<MessageInfo> messageInfoList = new ArrayList<MessageInfo>(readSet.count()); for (int i = 0; i < readSet.count(); i++) { messageInfoList.add(indexMessages.get(readSet.getKeyAt(i))); } onSuccess(); return new StoreInfo(readSet, messageInfoList); } catch (StoreException e) { if (e.getErrorCode() == StoreErrorCodes.IOError) { onError(); } throw e; } catch (Exception e) { throw new StoreException("Unknown exception while trying to fetch blobs from store " + dataDir, e, StoreErrorCodes.Unknown_Error); } finally { context.stop(); } } BlobStore(ReplicaId replicaId, StoreConfig config, ScheduledExecutorService taskScheduler,
      ScheduledExecutorService longLivedTaskScheduler, DiskIOScheduler diskIOScheduler,
      DiskSpaceAllocator diskSpaceAllocator, StoreMetrics metrics, StoreMetrics storeUnderCompactionMetrics,
      StoreKeyFactory factory, MessageStoreRecovery recovery, MessageStoreHardDelete hardDelete,
      List<ReplicaStatusDelegate> replicaStatusDelegates, Time time, AccountService accountService);   BlobStore(String storeId, StoreConfig config, ScheduledExecutorService taskScheduler,
      ScheduledExecutorService longLivedTaskScheduler, DiskIOScheduler diskIOScheduler,
      DiskSpaceAllocator diskSpaceAllocator, StoreMetrics metrics, StoreMetrics storeUnderCompactionMetrics,
      String dataDir, long capacityInBytes, StoreKeyFactory factory, MessageStoreRecovery recovery,
      MessageStoreHardDelete hardDelete, Time time);   BlobStore(ReplicaId replicaId, String storeId, StoreConfig config, ScheduledExecutorService taskScheduler,
      ScheduledExecutorService longLivedTaskScheduler, DiskIOScheduler diskIOScheduler,
      DiskSpaceAllocator diskSpaceAllocator, StoreMetrics metrics, StoreMetrics storeUnderCompactionMetrics,
      String dataDir, long capacityInBytes, StoreKeyFactory factory, MessageStoreRecovery recovery,
      MessageStoreHardDelete hardDelete, List<ReplicaStatusDelegate> replicaStatusDelegates, Time time,
      AccountService accountService, BlobStoreStats blobStoreStats); @Override void start(); @Override StoreInfo get(List<? extends StoreKey> ids, EnumSet<StoreGetOptions> storeGetOptions); @Override void put(MessageWriteSet messageSetToWrite); @Override void delete(List<MessageInfo> infosToDelete); @Override void updateTtl(List<MessageInfo> infosToUpdate); @Override short undelete(MessageInfo info); @Override FindInfo findEntriesSince(FindToken token, long maxTotalSizeOfEntries); @Override Set<StoreKey> findMissingKeys(List<StoreKey> keys); @Override MessageInfo findKey(StoreKey key); @Override StoreStats getStoreStats(); @Override boolean isKeyDeleted(StoreKey key); @Override long getSizeInBytes(); long getLogEndOffsetInBytes(); @Override boolean isEmpty(); @Override boolean isBootstrapInProgress(); @Override boolean isDecommissionInProgress(); @Override void completeBootstrap(); @Override void setCurrentState(ReplicaState state); @Override ReplicaState getCurrentState(); @Override boolean recoverFromDecommission(); @Override boolean disabledOnError(); void deleteStoreFiles(); @Override long getEndPositionOfLastPut(); List<ReplicaStatusDelegate> getReplicaStatusDelegates(); @Override void shutdown(); @Override boolean isStarted(); @Override String toString();  }