Beispiel #1
0
  @Override
  public String createVolume(int sizeGB, String snapshotId) {
    IaasProvider iaasInfo = getIaasProvider();

    ComputeServiceContext context = iaasInfo.getComputeService().getContext();

    String region = ComputeServiceBuilderUtil.extractRegion(iaasInfo);
    String zone = ComputeServiceBuilderUtil.extractZone(iaasInfo);

    if (region == null || zone == null) {
      log.fatal(
          "Cannot create a new volume in the [region] : "
              + region
              + ", [zone] : "
              + zone
              + " of Iaas : "
              + iaasInfo);
      return null;
    }

    ElasticBlockStoreApi blockStoreApi =
        context.unwrapApi(AWSEC2Api.class).getElasticBlockStoreApiForRegion(region).get();

    Volume volume;
    if (StringUtils.isEmpty(snapshotId)) {
      if (log.isDebugEnabled()) {
        log.info("Creating a volume in the zone " + zone);
      }
      volume = blockStoreApi.createVolumeInAvailabilityZone(zone, sizeGB);
    } else {
      if (log.isDebugEnabled()) {
        log.info("Creating a volume in the zone " + zone + " from the shanpshot " + snapshotId);
      }
      volume = blockStoreApi.createVolumeFromSnapshotInAvailabilityZone(zone, snapshotId);
    }

    if (volume == null) {
      log.fatal(
          "Volume creation was unsuccessful. [region] : "
              + region
              + ", [zone] : "
              + zone
              + " of Iaas : "
              + iaasInfo);
      return null;
    }

    log.info(
        "Successfully created a new volume [id]: "
            + volume.getId()
            + " in [region] : "
            + region
            + ", [zone] : "
            + zone
            + " of Iaas : "
            + iaasInfo);
    return volume.getId();
  }
  protected Volume.Factory extendStoreVolumeFactory() {
    long sizeLimit = propsGetLong(Keys.sizeLimit, 0);
    String volume = props.getProperty(Keys.volume);
    if (Keys.volume_heap.equals(volume)) return Volume.memoryFactory(false, sizeLimit);
    else if (Keys.volume_offheap.equals(volume)) return Volume.memoryFactory(true, sizeLimit);

    File file = new File(props.getProperty(Keys.file));

    return Volume.fileFactory(propsGetBool(Keys.readOnly), propsGetRafMode(), file, sizeLimit);
  }
 public String getVolumeID() {
   try {
     EmailID emailID = searchResult.getEmailId();
     Volume volume = emailID.getVolume();
     if (volume != null) {
       String volumeID = volume.getID();
       return volumeID;
     } else return null;
   } catch (MessageSearchException mse) {
     logger.debug("failed to retrieve volumeid: " + mse.getMessage(), mse);
     return null;
   }
   // return searchResult.getEmailId().getVolume().getID();
 }
 @Test
 public void in_memory_test() {
   StorageDirect engine = new StorageDirect(Volume.memoryFactory(false));
   Map<Long, Integer> recids = new HashMap<Long, Integer>();
   for (int i = 0; i < 1000; i++) {
     long recid = engine.recordPut(i, Serializer.BASIC_SERIALIZER);
     recids.put(recid, i);
   }
   for (Long recid : recids.keySet()) {
     assertEquals(recids.get(recid), engine.recordGet(recid, Serializer.BASIC_SERIALIZER));
   }
 }
Beispiel #5
0
  @Before
  static void navigation() {
    List<Volume> olderVolumes = Volume.find("order by pubYear desc").fetch(5);

    List<User> authors =
        User.find(
                "select a from User a " + "where a.paperCount > 0 " + "order by a.paperCount desc")
            .fetch();

    List<Numbers> numbers = Number.find("order by pubDate desc").fetch(5);

    renderArgs.put("numberList", numbers);
    renderArgs.put("volumeList", olderVolumes);
    renderArgs.put("authorList", authors);
  }