/** * Get quota (maximum) bytes for the given mailbox * * @param mailbox * @return */ public Long getQuotaBytes(final Mailbox mailbox) { // TODO: add account quota attribute check return Configurator.getDefaultQuotaBytes(); }
/** * Get quota (maximum) messages for the given mailbox * * @param mailbox * @return */ public Long getQuotaCount(final Mailbox mailbox) { // TODO: add account quota attribute check return Configurator.getDefaultQuotaCount(); }
public void start(BundleContext context) throws Exception { plugin = this; bundleContext = context; // Setup performance logger for POP3 if(Configurator.isPerformanceCountersEnabled()) { PeriodicalLog pLog = new PeriodicalLog(); pLog.setName(SPEED4J_LOG_NAME); pLog.setMode(PeriodicalLog.Mode.JMX_ONLY); pLog.setMaxQueueSize(250000); pLog.setPeriod(Configurator.getPerformanceCountersInterval()); pLog.setJmx("AUTH.success,AUTH.fail"); pLog.setSlf4jLogname("com.elasticinbox.speed4j.pop3.PeriodicalLogger"); stopWatchFactory = StopWatchFactory.getInstance(pLog); } else { Slf4jLog pLog = new Slf4jLog(); pLog.setName(SPEED4J_LOG_NAME); pLog.setSlf4jLogname("com.elasticinbox.speed4j.pop3.PeriodicalLogger"); stopWatchFactory = StopWatchFactory.getInstance(pLog); } backend = new MailboxHandlerFactory(); logger.debug("Starting POP3 daemon..."); server = new POP3ProxyServer(backend); server.start(); logger.info("POP3 daemon started."); }
long requiredCount = mailboxCounters.getTotalMessages() + 1; if ((requiredBytes > Configurator.getDefaultQuotaBytes()) || (requiredCount > Configurator.getDefaultQuotaCount())) Configurator.getDefaultQuotaBytes(), requiredCount, Configurator.getDefaultQuotaCount() }); Configurator.getBlobStoreWriteProfileName(), in, message.getSize()) .buildURI();
public Speed4jOpTimer() { // Instantiate a new Periodical logger PeriodicalLog pLog = new PeriodicalLog(); pLog.setName("ElasticInbox-Hector"); pLog.setPeriod(Configurator.getPerformanceCountersInterval()); pLog.setMode(PeriodicalLog.Mode.JMX_ONLY); pLog.setMaxQueueSize(250000); pLog.setJmx("READ.success,WRITE.success,READ.fail,WRITE.fail,META_READ.success,META_READ.fail"); pLog.setSlf4jLogname("com.elasticinbox.speed4j.cassandra.HectorPeriodicalLogger"); stopWatchFactory = StopWatchFactory.getInstance(pLog); }
if (updatedSize <= Configurator.getDatabaseBlobMaxSize()) updatedSize, Configurator.getDatabaseBlobMaxSize()); blobUri = dbBlobStorage.write(messageId, mailbox, null, in1, updatedSize); } else { logger.debug( "Storing Blob in the cloud because size ({}KB) was greater than database threshold {}KB", updatedSize, Configurator.getDatabaseBlobMaxSize()); blobUri = cloudBlobStorage.write(messageId, mailbox, Configurator.getBlobStoreWriteProfileName(), in1, updatedSize);
@Override public BlobURI write(final UUID messageId, final Mailbox mailbox, final String profileName, final InputStream in, final Long size) throws IOException, GeneralSecurityException { // get blob name String blobName = new BlobNameBuilder().setMailbox(mailbox) .setMessageId(messageId).setMessageSize(size).build(); InputStream in1; Long updatedSize = size; // prepare URI BlobURI blobUri = new BlobURI() .setProfile(profileName) .setName(blobName); // encrypt stream if (encryptionHandler != null) { byte[] iv = getCipherIVFromBlobName(blobName); InputStream encryptedInputStream = this.encryptionHandler.encrypt(in, Configurator.getBlobStoreDefaultEncryptionKey(), iv); FileBackedOutputStream fbout = new FileBackedOutputStream(MAX_MEMORY_FILE_SIZE, true); updatedSize = ByteStreams.copy(encryptedInputStream, fbout); in1 = fbout.getSupplier().getInput(); blobUri.setEncryptionKey(Configurator.getBlobStoreDefaultEncryptionKeyAlias()); } else { in1 = in; } CloudStoreProxy.write(blobName, profileName, in1, updatedSize); return blobUri; }
BlobStoreProfile profile = Configurator.getBlobStoreProfile(profileName); String path = BlobUtils.relativize(uri.getPath());
public void start(BundleContext context) throws Exception { plugin = this; bundleContext = context; // Setup performance logger for LMTP if(Configurator.isPerformanceCountersEnabled()) { LoggingPeriodicalLog pLog = new LoggingPeriodicalLog(); pLog.setName(SPEED4J_LOG_NAME); pLog.setMode(PeriodicalLog.Mode.JMX_ONLY); pLog.setMaxQueueSize(250000); pLog.setPeriod(Configurator.getPerformanceCountersInterval()); pLog.setJmx("DELIVERY.success,DELIVERY.discard,DELIVERY.defer,DELIVERY.defer_failure,DELIVERY.reject_overQuota,DELIVERY.reject_nonExistent"); pLog.setSlf4jLogname("com.elasticinbox.speed4j.lmtp.PeriodicalLogger"); stopWatchFactory = StopWatchFactory.getInstance(pLog); } else { Slf4jLog pLog = new Slf4jLog(); pLog.setName(SPEED4J_LOG_NAME); pLog.setSlf4jLogname("com.elasticinbox.speed4j.lmtp.PeriodicalLogger"); stopWatchFactory = StopWatchFactory.getInstance(pLog); } DeliveryAgentFactory mdf = new DeliveryAgentFactory(); backend = new MulticastDeliveryAgent(mdf.getDeliveryAgent()); logger.debug("Starting LMTP daemon..."); server = new LMTPProxyServer(backend); server.start(); logger.info("LMTP daemon started."); }
/** * Read Blob contents * * @param uri * @return */ public static InputStream read(URI uri) { // check if blob was stored for the message Assert.notNull(uri, "URI cannot be null"); logger.debug("Reading blob {}", uri); String profileName = uri.getHost(); String container = Configurator.getBlobStoreProfile(profileName).getContainer(); BlobStoreContext context = getBlobStoreContext(profileName); String path = BlobUtils.relativize(uri.getPath()); InputStream in = context.getBlobStore() .getBlob(container, path) .getPayload().getInput(); return in; }
BlobStoreProfile profile = Configurator.getBlobStoreProfile(profileName); ContextBuilder contextBuilder = ContextBuilder.newBuilder(profile.getProvider());
/** * Store Blob * * @param blobName * Blob filename including relative path * @param profileName * Blob store profile name * @param in * Payload * @param size * Payload size in bytes * @return * @throws IOException */ public static void write(final String blobName, final String profileName, InputStream in, final Long size) throws IOException, GeneralSecurityException { Assert.notNull(in, "No data to store"); Assert.notNull(size, "Blob size must be specified"); final String container = Configurator.getBlobStoreProfile(profileName).getContainer(); BlobStoreContext context = getBlobStoreContext(profileName); logger.debug("Storing blob {} on {}", blobName, profileName); BlobStore blobStore = context.getBlobStore(); BlobBuilder blobBuilder = blobStore.blobBuilder(blobName).payload(in).contentLength(size); // store blob blobStore.putBlob(container, blobBuilder.build()); }