本文整理汇总了Java中com.redhat.victims.database.VictimsDBInterface.synchronize方法的典型用法代码示例。如果您正苦于以下问题:Java VictimsDBInterface.synchronize方法的具体用法?Java VictimsDBInterface.synchronize怎么用?Java VictimsDBInterface.synchronize使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.redhat.victims.database.VictimsDBInterface
的用法示例。
在下文中一共展示了VictimsDBInterface.synchronize方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testDerby
import com.redhat.victims.database.VictimsDBInterface; //导入方法依赖的package包/类
@Test(expected = VictimsException.class)
public void testDerby() throws IOException, VictimsException {
String old = System.getProperty(VictimsConfig.Key.DB_DRIVER);
try {
System.setProperty(VictimsConfig.Key.DB_DRIVER,
"org.apache.derby.jdbc.EmbeddedDriver");
VictimsDBInterface vdb = VictimsDB.db();
vdb.synchronize();
} finally {
if (old != null) {
System.setProperty(VictimsConfig.Key.DB_DRIVER, old);
} else {
System.clearProperty(VictimsConfig.Key.DB_DRIVER);
}
}
}
示例2: getVictimsDB
import com.redhat.victims.database.VictimsDBInterface; //导入方法依赖的package包/类
/**
* sync and return victims db
*
* @return victims db
*/
private VictimsDBInterface getVictimsDB() {
VictimsDBInterface db = null;
try {
db = VictimsDB.db();
//todo add option and logic to set update interval
db.synchronize();
} catch (Exception ex) {
log.error(ex.getMessage(), ex);
}
return db;
}
示例3: testPurgeOnSync
import com.redhat.victims.database.VictimsDBInterface; //导入方法依赖的package包/类
@Test
public void testPurgeOnSync() throws VictimsException {
String hash = "0";
VictimsResultCache vrc = prepareCache(hash);
VictimsDBInterface vdb = VictimsDB.db();
vdb.synchronize();
assertTrue("Cache was not correctly purged on database sync.",
!vrc.exists(hash));
}
示例4: execute
import com.redhat.victims.database.VictimsDBInterface; //导入方法依赖的package包/类
@Override
public CommandResult execute(List<String> args) {
try {
VictimsDBInterface db = VictimsDB.db();
db.synchronize();
ExitSuccess result = new ExitSuccess(null);
result.addVerboseOutput("synchronization complete!");
return result;
} catch (VictimsException e){
//e.printStackTrace();
return new ExitFailure(e.getMessage());
}
}
示例5: updateDatabase
import com.redhat.victims.database.VictimsDBInterface; //导入方法依赖的package包/类
/**
* Updates the database according to the given configuration
*
* @param ctx
* @throws VictimsException
*/
public void updateDatabase(ExecutionContext ctx) throws VictimsException {
VictimsDBInterface db = ctx.getDatabase();
LogOutputResource log = ctx.getLog();
Date updated = db.lastUpdated();
// update automatically every time
if (ctx.updateAlways()) {
log.log(TextUI.fmt(Resources.INFO_UPDATES, updated.toString(),
VictimsConfig.uri()), LogLevel.INFO.getLevel());
db.synchronize();
// update once per day
} else if (ctx.updateDaily()) {
Date today = new Date();
SimpleDateFormat cmp = new SimpleDateFormat("yyyMMdd");
boolean updatedToday = cmp.format(today)
.equals(cmp.format(updated));
if (!updatedToday) {
log.log(TextUI.fmt(Resources.INFO_UPDATES, updated.toString(),
VictimsConfig.uri()), LogLevel.INFO.getLevel());
db.synchronize();
} else {
log.log("Database last synchronized: " + updated.toString(),
LogLevel.DEBUG.getLevel());
}
// updates disabled
} else {
log.log("Database synchronization disabled.",
LogLevel.INFO.getLevel());
}
}
示例6: updateDatabase
import com.redhat.victims.database.VictimsDBInterface; //导入方法依赖的package包/类
/**
* Updates the database according to the given configuration
*
* @param ctx
* @throws VictimsException
*/
private void updateDatabase(ExecutionContext context)
throws VictimsException {
VictimsDBInterface db = context.getDatabase();
PrintStream log = context.getLog();
Date updated = db.lastUpdated();
// update: auto
if (context.updateAlways()) {
log.println("Updating database");
db.synchronize();
} else if (context.updateDaily()) { // update: daily
Date today = new Date();
SimpleDateFormat cmp = new SimpleDateFormat("yyyyMMdd");
boolean updatedToday = cmp.format(today)
.equals(cmp.format(updated));
if (!updatedToday) {
log.println("Updating database");
db.synchronize();
} else {
log.println("Database last updated: "
+ updated.toString());
}
} else { // update: disabled
log.println("Database synchronization disabled.");
}
}
示例7: testResync
import com.redhat.victims.database.VictimsDBInterface; //导入方法依赖的package包/类
@Test
public void testResync() throws VictimsException {
VictimsDBInterface vdb = VictimsDB.db();
vdb.synchronize();
}
示例8: updateDatabase
import com.redhat.victims.database.VictimsDBInterface; //导入方法依赖的package包/类
/**
* Updates the database according to the given configuration
*
* @param ctx
* context setting for this execution of the scan
* @throws VictimsException
*/
public void updateDatabase(ExecutionContext ctx) throws VictimsException {
VictimsDBInterface db = ctx.getDatabase();
ILog log = ctx.getLog();
Date updated = db.lastUpdated();
// update automatically every time
if (ctx.updateAlways()) {
log.log(new Status(Status.INFO, Activator.PLUGIN_ID, (TextUI.fmt(
Resources.INFO_UPDATES, updated.toString(),
VictimsConfig.uri()))));
db.synchronize();
// update once per day
} else if (ctx.updateDaily()) {
Date today = new Date();
SimpleDateFormat cmp = new SimpleDateFormat("yyyMMdd");
boolean updatedToday = cmp.format(today)
.equals(cmp.format(updated));
if (!updatedToday) {
log.log(new Status(Status.INFO, Activator.PLUGIN_ID, TextUI
.fmt(Resources.INFO_UPDATES, updated.toString(),
VictimsConfig.uri())));
db.synchronize();
} else {
log.log(new Status(Status.INFO, Activator.PLUGIN_ID,
"Database last synchronized: " + updated.toString()));
}
// updates disabled
} else {
log.log(new Status(Status.INFO, Activator.PLUGIN_ID,
"Database synchronization disabled."));
}
}