@Override public boolean execute() { boolean retVal = true; StopWatch watch = new StopWatch(); try { watch.start(); LOGGER.debug("In generator"); TenantBlobSizeQueue queue = (TenantBlobSizeQueue) getWorkQueue(); // get all tenantIds List<TenantIdMasterEntity> listTenant = tenantIdMasterDao.getAllTenants(); for (Iterator<TenantIdMasterEntity> iterator = listTenant.iterator(); iterator.hasNext(); ) { TenantIdMasterEntity tenant = (TenantIdMasterEntity) iterator.next(); String tenantId = tenant.getTenantId(); // put each tenant Id in queue queue.enqueue(tenantId); LOGGER.info("Generator : msg added is " + tenantId); } watch.stop(); taskCompletionDao.updateTaskCompletionDetails( watch.getTotalTimeSeconds(), "GenerateMeterBlobSizeWork", "Measure blob size for " + listTenant.size() + " tenants"); } catch (StorageException e) { retVal = false; LOGGER.error(e.getMessage(), e); } return retVal; }
/** Calculates the blob sizes of private and public container. */ @Override public boolean execute() { boolean retVal = true; String tenantId = null; long blobSize = 0; try { LOGGER.debug("In Processor"); TenantBlobSizeQueue queue = (TenantBlobSizeQueue) getWorkQueue(); tenantId = queue.dequeue(SchedulerSettings.MessageVisibilityTimeout); if (tenantId == null) { retVal = false; LOGGER.debug("Processor : msg is null"); } else { StopWatch watch = new StopWatch(); watch.start(); // get the size of blobs in private container. blobSize = storageUtility.getContainerSize("tntp-" + tenantId.toLowerCase()); // get the size of blobs in public container. blobSize = blobSize + storageUtility.getContainerSize("tnts-" + tenantId.toLowerCase()); LOGGER.debug("Processor : msg is " + tenantId); MeteringEntity metering = new MeteringEntity(); metering.setTenantId(tenantId); Calendar calendar = Calendar.getInstance(); SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.S z"); dateFormat.setTimeZone(TimeZone.getTimeZone("UTC")); String date = dateFormat.format(calendar.getTime()); metering.setSnapshotTime(dateFormat.parse(date)); // set the calculated size blobSize = blobSize / 1024; metering.setBlobStoreUsage(blobSize); meteringDao.add(metering); LOGGER.info("Processor : blobSize is " + blobSize); watch.stop(); taskCompletionDao.updateTaskCompletionDetails( watch.getTotalTimeSeconds(), "ProcessMeteringBlobSizes", "Measured " + blobSize + " kb for tenant " + tenantId); } } catch (Exception e) { retVal = false; LOGGER.error(e.getMessage(), e); } return retVal; }