Example usage for javax.ejb TransactionAttributeType NOT_SUPPORTED

List of usage examples for javax.ejb TransactionAttributeType NOT_SUPPORTED

Introduction

In this page you can find the example usage for javax.ejb TransactionAttributeType NOT_SUPPORTED.

Prototype

TransactionAttributeType NOT_SUPPORTED

To view the source code for javax.ejb TransactionAttributeType NOT_SUPPORTED.

Click Source Link

Document

The container invokes an enterprise bean method whose transaction attribute NOT_SUPPORTED with an unspecified transaction context.

Usage

From source file:org.rhq.enterprise.server.cloud.StorageNodeManagerBean.java

@Override
@RequiredPermission(Permission.MANAGE_SETTINGS)
@TransactionAttribute(TransactionAttributeType.NOT_SUPPORTED)
public void undeployStorageNode(Subject subject, StorageNode storageNode) {
    StorageNodeCriteria c = new StorageNodeCriteria();
    c.addFilterId(storageNode.getId());/*w w  w  .  j av a 2s  .  c  om*/
    c.fetchResource(true);
    List<StorageNode> storageNodes = storageNodeManager.findStorageNodesByCriteria(subject, c);
    if (storageNodes.isEmpty()) {
        throw new RuntimeException("Storage node not found, can not undeploy " + storageNode);
    }
    storageNode = storageNodes.get(0);

    switch (storageNode.getOperationMode()) {
    case INSTALLED:
        storageNodeManager.resetInNewTransaction();
        storageNodeOperationsHandler.uninstall(subject, storageNode);
        break;
    case ANNOUNCE:
    case BOOTSTRAP:
        storageNodeManager.resetInNewTransaction();
        storageNodeOperationsHandler.unannounceStorageNode(subject, storageNode);
        break;
    case ADD_MAINTENANCE:
    case NORMAL:
    case DECOMMISSION:
        storageNodeManager.resetInNewTransaction();
        storageNodeOperationsHandler.decommissionStorageNode(subject, storageNode);
        break;
    case REMOVE_MAINTENANCE:
        storageNodeManager.resetInNewTransaction();
        storageNodeOperationsHandler.performRemoveNodeMaintenance(subject, storageNode);
        break;
    case UNANNOUNCE:
        storageNodeManager.resetInNewTransaction();
        storageNodeOperationsHandler.unannounceStorageNode(subject, storageNode);
        break;
    case UNINSTALL:
        storageNodeManager.resetInNewTransaction();
        storageNodeOperationsHandler.uninstall(subject, storageNode);
        break;
    default:
        // TODO what do we do with/about maintenance mode
        throw new RuntimeException("Cannot undeploy " + storageNode);
    }
}

From source file:org.rhq.enterprise.server.cloud.StorageNodeManagerBean.java

@Override
@RequiredPermission(Permission.MANAGE_SETTINGS)
@TransactionAttribute(TransactionAttributeType.NOT_SUPPORTED)
public void runClusterMaintenance(Subject subject) {
    List<StorageNode> storageNodes = storageNodeManager.getClusterNodes();

    if (storageNodes.size() == 1) {
        log.info("Skipping scheduled repair since this is a single-node cluster");
    } else {/*from   w ww .j a v  a 2  s .c o  m*/
        storageNodeOperationsHandler.runRepair(subjectManager.getOverlord(), storageNodes);
    }
}

From source file:org.rhq.enterprise.server.measurement.CallTimeDataManagerBean.java

@TransactionAttribute(TransactionAttributeType.NOT_SUPPORTED)
public void addCallTimeData(@NotNull Set<CallTimeData> callTimeDataSet) {
    if (callTimeDataSet.isEmpty()) {
        return;/*  ww w. j  av  a2s  .  co m*/
    }

    log.debug("Persisting call-time data for " + callTimeDataSet.size() + " schedules...");
    long startTime = System.currentTimeMillis();

    // First make sure a single row exists in the key table for each reported call destination.
    callTimeDataManager.insertCallTimeDataKeys(callTimeDataSet);

    // Finally, add the stats themselves to the value table.
    callTimeDataManager.insertCallTimeDataValues(callTimeDataSet);
    MeasurementMonitor.getMBean().incrementCallTimeInsertTime(System.currentTimeMillis() - startTime);

}

From source file:org.rhq.enterprise.server.measurement.MeasurementCompressionManagerBean.java

@TransactionAttribute(TransactionAttributeType.NOT_SUPPORTED)
public void compressPurgeAndTruncate() throws SQLException {
    loadPurgeDefaults();//w  ww.j  a v a2  s.  co m

    // current time rounded down to the start of this hour.
    long now = TimingVoodoo.roundDownTime(System.currentTimeMillis(), HOUR);

    // Compress hourly data
    long hourAgo = TimingVoodoo.roundDownTime(now - HOUR, HOUR);
    String deadTable = MeasurementDataManagerUtility.getDeadTable(hourAgo);
    int deadTableIndex = MeasurementDataManagerUtility.getTableNameIndex(deadTable);
    String[] rawTables = MeasurementDataManagerUtility.getAllRawTables(deadTableIndex + 1);

    // compress uncompressed raw data in the non-dead tables. Go through all of the tables
    // to handle missed compressions due to a downed server. Start with the oldest data first so that
    // we build up the history correctly (because compression rolls forward in time.)
    // NOTE : This is somewhat inefficient for a running server actively collecting raw data as
    // NOTE : in general we'll only really need to process the "now" table. Although, 
    // NOTE : compressionManager.compressData has an optimization to return quickly if there is no work.
    for (String rawTable : rawTables) {
        if (!rawTable.equals(deadTable)) {
            compressData(rawTable, TAB_DATA_1H, HOUR, now);
        }
    }

    // truncate the dead table. Note that we may truncate the same table repeatedly during a 12 hour cycle, this is OK, it's fast
    compressionManager.truncateMeasurements(deadTable);

    // begin time of last compression period
    long last;

    // Compress 6 hour data
    last = compressData(TAB_DATA_1H, TAB_DATA_6H, SIX_HOUR, now);

    // Purge, ensuring we don't purge data not yet compressed.
    purgeMeasurements(TAB_DATA_1H, Math.min(now - this.purge1h, last), HOUR);

    // Compress daily data
    last = compressData(TAB_DATA_6H, TAB_DATA_1D, DAY, now);

    // Purge, ensuring we don't purge data not yet compressed.
    purgeMeasurements(TAB_DATA_6H, Math.min(now - this.purge6h, last), SIX_HOUR);

    // Purge, we never store more than 1 year of data.
    purgeMeasurements(TAB_DATA_1D, now - this.purge1d, DAY);

    return;
}

From source file:org.rhq.enterprise.server.measurement.MeasurementCompressionManagerBean.java

@TransactionAttribute(TransactionAttributeType.NOT_SUPPORTED)
public void truncateMeasurements(String tableName) throws SQLException {
    // Make sure we only truncate the dead table... other tables may have live data in them
    if (tableName.equals(MeasurementDataManagerUtility.getDeadTable(System.currentTimeMillis()))) {
        Connection conn = null;//from  w w  w  .  ja v  a2 s.com
        Statement stmt = null;
        StopWatch watch = new StopWatch();
        try {
            conn = ((DataSource) ctx.lookup(DATASOURCE_NAME)).getConnection();
            stmt = conn.createStatement();
            long startTime = System.currentTimeMillis();
            stmt.executeUpdate("TRUNCATE TABLE " + tableName);
            MeasurementMonitor.getMBean().incrementPurgeTime(System.currentTimeMillis() - startTime);
        } finally {
            JDBCUtil.safeClose(conn, stmt, null);
            log.info("Truncated table [" + tableName + "] in [" + (watch.getElapsed() / SECOND) + "] seconds");
        }
    }
}

From source file:org.rhq.enterprise.server.measurement.MeasurementDataManagerBean.java

@TransactionAttribute(TransactionAttributeType.NOT_SUPPORTED)
public void mergeMeasurementReport(MeasurementReport report) {
    long start = System.currentTimeMillis();
    // TODO GH: Deal with offset (this is only for situations where the clock doesn't match on the agent)

    /*/*from   w ww  .  j  a  v  a  2 s .  c o  m*/
     * even if these methods check for null/empty collections, they cross the EJB boundary and so unnecessarily
     * start transactions.  by checking the null/emptiness of a collection here, by only create transactions
     * when real work will be done;
     */
    if (report.getNumericData() != null && !report.getNumericData().isEmpty()) {
        this.measurementDataManager.addNumericData(report.getNumericData());
    }
    if (report.getTraitData() != null && !report.getTraitData().isEmpty()) {
        this.measurementDataManager.addTraitData(report.getTraitData());
    }
    if (report.getCallTimeData() != null && !report.getCallTimeData().isEmpty()) {
        this.callTimeDataManager.addCallTimeData(report.getCallTimeData());
    }

    long time = System.currentTimeMillis() - start;
    MeasurementMonitor.getMBean().incrementMeasurementInsertTime(time);
    MeasurementMonitor.getMBean().incrementMeasurementsInserted(report.getDataCount());

    if (log.isDebugEnabled()) {
        log.debug("Measurement storage for [" + report.getDataCount() + "] took " + time + "ms");
    }
}

From source file:org.rhq.enterprise.server.resource.group.ResourceGroupManagerBean.java

@TransactionAttribute(TransactionAttributeType.NOT_SUPPORTED)
@RequiredPermission(Permission.MANAGE_INVENTORY)
public void uninventoryMembers(Subject subject, int groupId) {
    List<Integer> resourceMemberIds = resourceManager.findExplicitResourceIdsByResourceGroup(groupId);
    for (int doomedResourceId : resourceMemberIds) {
        resourceManager.uninventoryResource(subject, doomedResourceId);
    }/*from ww w.  java  2s . c om*/
}

From source file:org.rhq.enterprise.server.storage.StorageClientManager.java

@TransactionAttribute(TransactionAttributeType.NOT_SUPPORTED)
public MetricsDAO getMetricsDAO() {
    return metricsDAO;
}

From source file:org.rhq.enterprise.server.storage.StorageClientManager.java

@TransactionAttribute(TransactionAttributeType.NOT_SUPPORTED)
public MetricsServer getMetricsServer() {
    return metricsServer;
}

From source file:org.rhq.enterprise.server.storage.StorageClientManager.java

@TransactionAttribute(TransactionAttributeType.NOT_SUPPORTED)
public StorageSession getSession() {
    return session;
}