use of com.orientechnologies.orient.server.config.OServerParameterConfiguration in project orientdb by orientechnologies.
the class AutomaticBackupTest method testFullBackupWithJsonConfigInclude.
@Test
public void testFullBackupWithJsonConfigInclude() throws IOException, ClassNotFoundException, MalformedObjectNameException, InstanceAlreadyExistsException, NotCompliantMBeanException, MBeanRegistrationException {
if (new File(BACKUPDIR + "/testautobackup.zip").exists())
new File(BACKUPDIR + "/testautobackup.zip").delete();
Assert.assertFalse(new File(tempDirectory + "/config/automatic-backup.json").exists());
String jsonConfig = OIOUtils.readStreamAsString(getClass().getResourceAsStream("automatic-backup.json"));
ODocument doc = new ODocument().fromJSON(jsonConfig);
doc.field("enabled", true);
doc.field("targetFileName", "${DBNAME}.zip");
doc.field("dbInclude", new String[] { "testautobackup" });
doc.field("firstTime", new SimpleDateFormat("HH:mm:ss").format(new Date(System.currentTimeMillis() + 2000)));
OIOUtils.writeFile(new File(tempDirectory + "/config/automatic-backup.json"), doc.toJSON());
final OAutomaticBackup aBackup = new OAutomaticBackup();
final OServerParameterConfiguration[] config = new OServerParameterConfiguration[] {};
aBackup.config(server, config);
try {
Thread.sleep(5000);
} catch (InterruptedException e) {
e.printStackTrace();
}
aBackup.sendShutdown();
final ODatabaseDocumentTx database2 = new ODatabaseDocumentTx(URL2);
if (database2.exists())
database2.open("admin", "admin").drop();
database2.create();
database2.restore(new FileInputStream(BACKUPDIR + "/testautobackup.zip"), null, null, null);
Assert.assertEquals(database2.countClass("TestBackup"), 1);
}
use of com.orientechnologies.orient.server.config.OServerParameterConfiguration in project orientdb by orientechnologies.
the class AutomaticBackupTest method testExport.
// // @Test
// //TODO: move to EE test suite
// public void testIncrementalBackup() throws IOException, ClassNotFoundException, MalformedObjectNameException,
// InstanceAlreadyExistsException, NotCompliantMBeanException, MBeanRegistrationException {
// if (new File(BACKUPDIR + "/" + DBNAME).exists())
// OFileUtils.deleteRecursively(new File(BACKUPDIR + "/" + DBNAME));
//
// final OAutomaticBackup aBackup = new OAutomaticBackup();
//
// final OServerParameterConfiguration[] config = new OServerParameterConfiguration[] {
// new OServerParameterConfiguration("firstTime",
// new SimpleDateFormat("HH:mm:ss").format(new Date(System.currentTimeMillis() + 2000))),
// new OServerParameterConfiguration("delay", "1d"), new OServerParameterConfiguration("mode", "INCREMENTAL_BACKUP"),
// new OServerParameterConfiguration("target.directory", BACKUPDIR) };
//
// aBackup.config(server, config);
//
// try {
// Thread.sleep(5000);
// } catch (InterruptedException e) {
// e.printStackTrace();
// }
//
// aBackup.sendShutdown();
//
// final ODatabaseDocumentTx database2 = new ODatabaseDocumentTx(URL2);
// if (database2.exists())
// database2.open("admin", "admin").drop();
// database2.create(BACKUPDIR + "/" + DBNAME);
//
// Assert.assertEquals(database2.countClass("TestBackup"), 1);
// }
@Test
public void testExport() throws IOException, ClassNotFoundException, MalformedObjectNameException, InstanceAlreadyExistsException, NotCompliantMBeanException, MBeanRegistrationException {
if (new File(BACKUPDIR + "/fullExport.json.gz").exists())
new File(BACKUPDIR + "/fullExport.json.gz").delete();
final OAutomaticBackup aBackup = new OAutomaticBackup();
final OServerParameterConfiguration[] config = new OServerParameterConfiguration[] { new OServerParameterConfiguration("firstTime", new SimpleDateFormat("HH:mm:ss").format(new Date(System.currentTimeMillis() + 2000))), new OServerParameterConfiguration("delay", "1d"), new OServerParameterConfiguration("mode", "EXPORT"), new OServerParameterConfiguration("target.directory", BACKUPDIR), new OServerParameterConfiguration("target.fileName", "fullExport.json.gz") };
aBackup.config(server, config);
try {
Thread.sleep(5000);
} catch (InterruptedException e) {
e.printStackTrace();
}
aBackup.sendShutdown();
final ODatabaseDocumentTx database2 = new ODatabaseDocumentTx(URL2);
if (database2.exists())
database2.open("admin", "admin").drop();
database2.create();
new ODatabaseImport(database2, BACKUPDIR + "/fullExport.json.gz", null).importDatabase();
Assert.assertEquals(database2.countClass("TestBackup"), 1);
}
use of com.orientechnologies.orient.server.config.OServerParameterConfiguration in project orientdb by orientechnologies.
the class OServerPluginManager method startPluginClass.
@SuppressWarnings("unchecked")
protected OServerPlugin startPluginClass(final String iClassName, final OServerParameterConfiguration[] params) throws Exception {
final Class<? extends OServerPlugin> classToLoad = (Class<? extends OServerPlugin>) Class.forName(iClassName);
final OServerPlugin instance = classToLoad.newInstance();
// CONFIG()
final Method configMethod = classToLoad.getDeclaredMethod("config", OServer.class, OServerParameterConfiguration[].class);
callListenerBeforeConfig(instance, params);
configMethod.invoke(instance, server, params);
callListenerAfterConfig(instance, params);
// STARTUP()
final Method startupMethod = classToLoad.getDeclaredMethod("startup");
callListenerBeforeStartup(instance);
startupMethod.invoke(instance);
callListenerAfterStartup(instance);
return instance;
}
use of com.orientechnologies.orient.server.config.OServerParameterConfiguration in project orientdb by orientechnologies.
the class OMailPlugin method config.
@Override
public void config(final OServer oServer, final OServerParameterConfiguration[] iParams) {
configuration = new ODocument();
for (OServerParameterConfiguration param : iParams) {
if (param.name.equalsIgnoreCase("enabled")) {
enabled = Boolean.parseBoolean(param.value);
configuration.field("enabled", enabled);
} else if (param.name.startsWith(CONFIG_PROFILE_PREFIX)) {
final String parts = param.name.substring(CONFIG_PROFILE_PREFIX.length());
int pos = parts.indexOf('.');
if (pos == -1)
continue;
final String profileName = parts.substring(0, pos);
final String profileParam = parts.substring(pos + 1);
OMailProfile profile = profiles.get(profileName);
if (profile == null) {
profile = new OMailProfile();
profiles.put(profileName, profile);
}
if (profileParam.startsWith(CONFIG_MAIL_PREFIX)) {
profile.put(profileParam, param.value);
}
}
}
List<Map<String, String>> profilesDocuments = new ArrayList<Map<String, String>>();
for (String p : profiles.keySet()) {
OMailProfile oMailProfile = profiles.get(p);
Map<String, String> properties = new HashMap<String, String>();
Set<String> strings = oMailProfile.stringPropertyNames();
for (String string : strings) {
properties.put(string, oMailProfile.getProperty(string));
}
properties.put("name", p);
profilesDocuments.add(properties);
}
configuration.field("profiles", profilesDocuments);
configure();
OLogManager.instance().info(this, "Installing Mail plugin, loaded %d profile(s): %s", profiles.size(), profiles.keySet());
}
use of com.orientechnologies.orient.server.config.OServerParameterConfiguration in project orientdb by orientechnologies.
the class OLiveQueryPlugin method config.
@Override
public void config(final OServer iServer, final OServerParameterConfiguration[] iParams) {
enabled = false;
super.config(iServer, iParams);
for (OServerParameterConfiguration param : iParams) {
if (param.name.equalsIgnoreCase("enabled")) {
if (Boolean.parseBoolean(param.value))
enabled = true;
}
}
}
Aggregations