当前位置: 首页>>代码示例>>Java>>正文


Java ExecutorService类代码示例

本文整理汇总了Java中liquibase.executor.ExecutorService的典型用法代码示例。如果您正苦于以下问题:Java ExecutorService类的具体用法?Java ExecutorService怎么用?Java ExecutorService使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


ExecutorService类属于liquibase.executor包,在下文中一共展示了ExecutorService类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: tag

import liquibase.executor.ExecutorService; //导入依赖的package包/类
@Override
    public void tag(final String tagString) throws DatabaseException {
        Database database = getDatabase();
        Executor executor = ExecutorService.getInstance().getExecutor(database);
        try {
            int totalRows = ExecutorService.getInstance().getExecutor(database).queryForInt(new SelectFromDatabaseChangeLogStatement(new ColumnConfig().setName("COUNT(*)", true)));
            if (totalRows == 0) {
                ChangeSet emptyChangeSet = new ChangeSet(String.valueOf(new Date().getTime()), "liquibase", false, false, "liquibase-internal", null, null, getDatabase().getObjectQuotingStrategy(), null);
                this.setExecType(emptyChangeSet, ChangeSet.ExecType.EXECUTED);
            }

//            Timestamp lastExecutedDate = (Timestamp) this.getExecutor().queryForObject(createChangeToTagSQL(), Timestamp.class);
            executor.execute(new TagDatabaseStatement(tagString));
            getDatabase().commit();

            if (this.ranChangeSetList != null) {
                ranChangeSetList.get(ranChangeSetList.size() - 1).setTag(tagString);
            }
        } catch (Exception e) {
            throw new DatabaseException(e);
        }
    }
 
开发者ID:eselyavka,项目名称:liquibase-impala,代码行数:23,代码来源:HiveStandardChangeLogHistoryService.java

示例2: generateStatements

import liquibase.executor.ExecutorService; //导入依赖的package包/类
@Override
public SqlStatement[] generateStatements(final Database database)
{
	validateParameters();

	final Executor currentExecutor = ExecutorService.getInstance().getExecutor(database);

	if (startOrStop == START_OR_STOP.START)
	{
		startSuppressing(database, currentExecutor);
	}
	else if (startOrStop == START_OR_STOP.STOP)
	{
		stopSuppressing(database, currentExecutor);
	}
	else
	{
		throw new IllegalArgumentException("Unknown startOrStop value " + startOrStop.name());
	}

	return new SqlStatement[] {};
}
 
开发者ID:Jurrie,项目名称:liquibase-suppress-output,代码行数:23,代码来源:SuppressOutputChange.java

示例3: generateRollbackStatements

import liquibase.executor.ExecutorService; //导入依赖的package包/类
@Override
public SqlStatement[] generateRollbackStatements(final Database database) throws RollbackImpossibleException
{
	validateParameters();

	final Executor currentExecutor = ExecutorService.getInstance().getExecutor(database);

	if (startOrStop == START_OR_STOP.START)
	{
		stopSuppressing(database, currentExecutor);
	}
	else if (startOrStop == START_OR_STOP.STOP)
	{
		startSuppressing(database, currentExecutor);
	}
	else
	{
		throw new IllegalArgumentException("Unknown startOrStop value " + startOrStop.name());
	}

	return new SqlStatement[] {};
}
 
开发者ID:Jurrie,项目名称:liquibase-suppress-output,代码行数:23,代码来源:SuppressOutputChange.java

示例4: close

import liquibase.executor.ExecutorService; //导入依赖的package包/类
@Override
public void close() throws DatabaseException {

    // copy-paste from AbstractJdbcDatabase plus reflection to deal with private fields...

    ExecutorService.getInstance().clearExecutor(this);
    DatabaseConnection connection = getConnection();
    if (connection != null) {

        Boolean previousAutoCommit = previousAutoCommit();
        if (previousAutoCommit != null) {
            try {
                connection.setAutoCommit(previousAutoCommit);
            } catch (DatabaseException e) {
                LogFactory.getInstance().getLog().warning("Failed to restore the auto commit to " + previousAutoCommit);
                throw e;
            }
        }
        connection.close();
    }
}
 
开发者ID:bootique,项目名称:bootique-liquibase,代码行数:22,代码来源:DerbyDatabase.java

示例5: setup

import liquibase.executor.ExecutorService; //导入依赖的package包/类
@Before
public void setup() {
    System.setProperty(Configuration.LIQUIBASE_PASSWORD, "root");

    database = new MySQLDatabase();
    database.setLiquibaseSchemaName("testdb");
    DatabaseConnection conn = new MockDatabaseConnection("jdbc:mysql://[email protected]:3306/testdb",
            "[email protected]");
    database.setConnection(conn);
    ExecutorService.getInstance().setExecutor(database, new JdbcExecutor());

    PTOnlineSchemaChangeStatement.available = true;
    PTOnlineSchemaChangeStatement.perconaToolkitVersion = null;
    System.setProperty(Configuration.FAIL_IF_NO_PT, "false");
    System.setProperty(Configuration.NO_ALTER_SQL_DRY_MODE, "false");
    System.setProperty(Configuration.SKIP_CHANGES, "");

    setupChange(change);
}
 
开发者ID:adangel,项目名称:liquibase-percona,代码行数:20,代码来源:AbstractPerconaChangeTest.java

示例6: tag

import liquibase.executor.ExecutorService; //导入依赖的package包/类
/**
     * Tags the database changelog with the given string.
     */
    public void tag(String tagString) throws DatabaseException {
        Executor executor = ExecutorService.getInstance().getExecutor(this);
        try {
            int totalRows = ExecutorService.getInstance().getExecutor(this).queryForInt(new SelectFromDatabaseChangeLogStatement("COUNT(*)"));
            if (totalRows == 0) {
                ChangeSet emptyChangeSet = new ChangeSet(String.valueOf(new Date().getTime()), "liquibase", false, false, "liquibase-internal", null, null);
                this.markChangeSetExecStatus(emptyChangeSet, ChangeSet.ExecType.EXECUTED);
            }

//            Timestamp lastExecutedDate = (Timestamp) this.getExecutor().queryForObject(createChangeToTagSQL(), Timestamp.class);
            executor.execute(new TagDatabaseStatement(tagString));
            this.commit();

            getRanChangeSetList().get(getRanChangeSetList().size() - 1).setTag(tagString);
        } catch (Exception e) {
            throw new DatabaseException(e);
        }
    }
 
开发者ID:hongliangpan,项目名称:manydesigns.cn,代码行数:22,代码来源:AbstractDatabase.java

示例7: getViewDefinition

import liquibase.executor.ExecutorService; //导入依赖的package包/类
@Override
public String getViewDefinition(String schemaName, String viewName) throws DatabaseException {
    if (schemaName == null) {
        schemaName = convertRequestedSchemaToSchema(null);
    }
    List<String> defLines = (List<String>) ExecutorService.getInstance().getExecutor(this).queryForList(new GetViewDefinitionStatement(schemaName, viewName), String.class);
    StringBuffer sb = new StringBuffer();
    for (String defLine : defLines) {
        sb.append(defLine);
    }
    String definition = sb.toString();

    if (definition == null) {
        return null;
    }
    return CREATE_VIEW_AS_PATTERN.matcher(definition).replaceFirst("");
}
 
开发者ID:hongliangpan,项目名称:manydesigns.cn,代码行数:18,代码来源:MSSQLDatabase.java

示例8: check

import liquibase.executor.ExecutorService; //导入依赖的package包/类
public void check(Database database, DatabaseChangeLog changeLog, ChangeSet changeSet) throws PreconditionFailedException, PreconditionErrorException {
    DatabaseConnection connection = database.getConnection();
    try {
        String result = (String) ExecutorService.getInstance().getExecutor(database).queryForObject(new RawSqlStatement(getSql().replaceFirst(";$","")), String.class);
        if (result == null) {
            throw new PreconditionFailedException("No rows returned from SQL Precondition", changeLog, this);
        }

        if (!expectedResult.equals(result)) {
            throw new PreconditionFailedException("SQL Precondition failed.  Expected '"+expectedResult+"' got '"+result+"'", changeLog, this);
        }

    } catch (DatabaseException e) {
        throw new PreconditionErrorException(e, changeLog, this);
    }
}
 
开发者ID:hongliangpan,项目名称:manydesigns.cn,代码行数:17,代码来源:SqlPrecondition.java

示例9: listLocks

import liquibase.executor.ExecutorService; //导入依赖的package包/类
public DatabaseChangeLogLock[] listLocks() throws LockException {
    try {
        if (!database.hasDatabaseChangeLogLockTable()) {
            return new DatabaseChangeLogLock[0];
        }

        List<DatabaseChangeLogLock> allLocks = new ArrayList<DatabaseChangeLogLock>();
        SqlStatement sqlStatement = new SelectFromDatabaseChangeLogLockStatement("ID", "LOCKED", "LOCKGRANTED", "LOCKEDBY");
        List<Map> rows = ExecutorService.getInstance().getExecutor(database).queryForList(sqlStatement);
        for (Map columnMap : rows) {
            Object lockedValue = columnMap.get("LOCKED");
            Boolean locked;
            if (lockedValue instanceof Number) {
                locked = ((Number) lockedValue).intValue() == 1;
            } else {
                locked = (Boolean) lockedValue;
            }
            if (locked != null && locked) {
                allLocks.add(new DatabaseChangeLogLock(((Number) columnMap.get("ID")).intValue(), (Date) columnMap.get("LOCKGRANTED"), (String) columnMap.get("LOCKEDBY")));
            }
        }
        return allLocks.toArray(new DatabaseChangeLogLock[allLocks.size()]);
    } catch (Exception e) {
        throw new LockException(e);
    }
}
 
开发者ID:hongliangpan,项目名称:manydesigns.cn,代码行数:27,代码来源:LockService.java

示例10: readSequences

import liquibase.executor.ExecutorService; //导入依赖的package包/类
protected void readSequences(DatabaseSnapshot snapshot, String schema, DatabaseMetaData databaseMetaData)
		throws DatabaseException {
	Database database = snapshot.getDatabase();
	if (database.supportsSequences()) {
		updateListeners("Reading sequences for " + database.toString() + " ...");

		String convertedSchemaName = database.convertRequestedSchemaToSchema(schema);

		// noinspection unchecked
		List<String> sequenceNames = (List<String>) ExecutorService.getInstance().getExecutor(database)
				.queryForList(new SelectSequencesStatement(schema), String.class);

		if (sequenceNames != null) {
			for (String sequenceName : sequenceNames) {
				Sequence seq = new Sequence();
				seq.setName(sequenceName.trim());
				seq.setSchema(convertedSchemaName);

				snapshot.getSequences().add(seq);
			}
		}
	} else {
		updateListeners("Sequences not supported for " + database.toString() + " ...");
	}
}
 
开发者ID:hongliangpan,项目名称:manydesigns.cn,代码行数:26,代码来源:JdbcDatabaseSnapshotGenerator.java

示例11: readSequences

import liquibase.executor.ExecutorService; //导入依赖的package包/类
@Override
protected void readSequences(DatabaseSnapshot snapshot, String schema, DatabaseMetaData databaseMetaData) throws DatabaseException {
    Database database = snapshot.getDatabase();
    updateListeners("Reading sequences for " + database.toString() + " ...");

    String convertedSchemaName = database.convertRequestedSchemaToSchema(schema);

    if (database.supportsSequences()) {
        //noinspection unchecked
        List<String> sequenceNamess = (List<String>) ExecutorService.getInstance().getExecutor(database).queryForList(new SelectSequencesStatement(schema), String.class);


        for (String sequenceName : sequenceNamess) {
            Sequence seq = new Sequence();
            seq.setName(sequenceName.trim());
            seq.setName(convertedSchemaName);

            snapshot.getSequences().add(seq);
        }
    }
}
 
开发者ID:hongliangpan,项目名称:manydesigns.cn,代码行数:22,代码来源:SQLiteDatabaseSnapshotGenerator.java

示例12: update

import liquibase.executor.ExecutorService; //导入依赖的package包/类
public void update(String contexts, Writer output) throws LiquibaseException {
    contexts = StringUtils.trimToNull(contexts);
    changeLogParameters.setContexts(StringUtils.splitAndTrim(contexts, ","));

    Executor oldTemplate = ExecutorService.getInstance().getExecutor(database);
    LoggingExecutor loggingExecutor = new LoggingExecutor(ExecutorService.getInstance().getExecutor(database), output, database);
    ExecutorService.getInstance().setExecutor(database, loggingExecutor);

    outputHeader("Update Database Script");

    LockService lockService = LockService.getInstance(database);
    lockService.waitForLock();

    try {

        update(contexts);

        output.flush();
    } catch (IOException e) {
        throw new LiquibaseException(e);
    } finally {
        lockService.releaseLock();
    }

    ExecutorService.getInstance().setExecutor(database, oldTemplate);
}
 
开发者ID:hongliangpan,项目名称:manydesigns.cn,代码行数:27,代码来源:Liquibase.java

示例13: rollback

import liquibase.executor.ExecutorService; //导入依赖的package包/类
public void rollback(int changesToRollback, String contexts, Writer output) throws LiquibaseException {
    contexts = StringUtils.trimToNull(contexts);
    changeLogParameters.setContexts(StringUtils.splitAndTrim(contexts, ","));

    Executor oldTemplate = ExecutorService.getInstance().getExecutor(database);
    ExecutorService.getInstance().setExecutor(database, new LoggingExecutor(ExecutorService.getInstance().getExecutor(database), output, database));

    outputHeader("Rollback " + changesToRollback + " Change(s) Script");

    rollback(changesToRollback, contexts);

    try {
        output.flush();
    } catch (IOException e) {
        throw new LiquibaseException(e);
    }
    ExecutorService.getInstance().setExecutor(database, oldTemplate);
}
 
开发者ID:hongliangpan,项目名称:manydesigns.cn,代码行数:19,代码来源:Liquibase.java

示例14: changeLogSync

import liquibase.executor.ExecutorService; //导入依赖的package包/类
public void changeLogSync(String contexts, Writer output) throws LiquibaseException {
    contexts = StringUtils.trimToNull(contexts);
    changeLogParameters.setContexts(StringUtils.splitAndTrim(contexts, ","));

    LoggingExecutor outputTemplate = new LoggingExecutor(ExecutorService.getInstance().getExecutor(database), output, database);
    Executor oldTemplate = ExecutorService.getInstance().getExecutor(database);
    ExecutorService.getInstance().setExecutor(database, outputTemplate);

    outputHeader("SQL to add all changesets to database history table");

    changeLogSync(contexts);

    try {
        output.flush();
    } catch (IOException e) {
        throw new LiquibaseException(e);
    }

    ExecutorService.getInstance().setExecutor(database, oldTemplate);
}
 
开发者ID:hongliangpan,项目名称:manydesigns.cn,代码行数:21,代码来源:Liquibase.java

示例15: markNextChangeSetRan

import liquibase.executor.ExecutorService; //导入依赖的package包/类
public void markNextChangeSetRan(String contexts, Writer output) throws LiquibaseException {
    contexts = StringUtils.trimToNull(contexts);
    changeLogParameters.setContexts(StringUtils.splitAndTrim(contexts, ","));


    LoggingExecutor outputTemplate = new LoggingExecutor(ExecutorService.getInstance().getExecutor(database), output, database);
    Executor oldTemplate = ExecutorService.getInstance().getExecutor(database);
    ExecutorService.getInstance().setExecutor(database, outputTemplate);

    outputHeader("SQL to add all changesets to database history table");

    markNextChangeSetRan(contexts);

    try {
        output.flush();
    } catch (IOException e) {
        throw new LiquibaseException(e);
    }

    ExecutorService.getInstance().setExecutor(database, oldTemplate);
}
 
开发者ID:hongliangpan,项目名称:manydesigns.cn,代码行数:22,代码来源:Liquibase.java


注:本文中的liquibase.executor.ExecutorService类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。