use of com.orientechnologies.orient.core.exception.OConfigurationException in project orientdb by orientechnologies.
the class ORuntimeKeyIndexDefinition method serializeFromStream.
@Override
protected void serializeFromStream() {
super.serializeFromStream();
final byte keySerializerId = ((Number) document.field("keySerializerId")).byteValue();
serializer = (OBinarySerializer<T>) OBinarySerializerFactory.getInstance().getObjectSerializer(keySerializerId);
if (serializer == null)
throw new OConfigurationException("Runtime index definition cannot find binary serializer with id=" + keySerializerId + ". Assure to plug custom serializer into the server.");
String collateField = document.field("collate");
if (collateField == null)
collateField = ODefaultCollate.NAME;
setNullValuesIgnored(!Boolean.FALSE.equals(document.<Boolean>field("nullValuesIgnored")));
}
use of com.orientechnologies.orient.core.exception.OConfigurationException in project orientdb by orientechnologies.
the class OSchemaShared method fromStream.
/**
* Binds ODocument to POJO.
*/
@Override
public void fromStream() {
rwSpinLock.acquireWriteLock();
modificationCounter.get().increment();
try {
// READ CURRENT SCHEMA VERSION
final Integer schemaVersion = (Integer) document.field("schemaVersion");
if (schemaVersion == null) {
OLogManager.instance().error(this, "Database's schema is empty! Recreating the system classes and allow the opening of the database but double check the integrity of the database");
return;
} else if (schemaVersion != CURRENT_VERSION_NUMBER && VERSION_NUMBER_V5 != schemaVersion) {
// HANDLE SCHEMA UPGRADE
throw new OConfigurationException("Database schema is different. Please export your old database with the previous version of OrientDB and reimport it using the current one.");
}
properties.clear();
propertiesByNameType.clear();
List<ODocument> globalProperties = document.field("globalProperties");
boolean hasGlobalProperties = false;
if (globalProperties != null) {
hasGlobalProperties = true;
for (ODocument oDocument : globalProperties) {
OGlobalPropertyImpl prop = new OGlobalPropertyImpl();
prop.fromDocument(oDocument);
ensurePropertiesSize(prop.getId());
properties.set(prop.getId(), prop);
propertiesByNameType.put(prop.getName() + "|" + prop.getType().name(), prop);
}
}
// REGISTER ALL THE CLASSES
clustersToClasses.clear();
final Map<String, OClass> newClasses = new HashMap<String, OClass>();
OClassImpl cls;
Collection<ODocument> storedClasses = document.field("classes");
for (ODocument c : storedClasses) {
cls = new OClassImpl(this, c, (String) c.field("name"));
cls.fromStream();
if (classes.containsKey(cls.getName().toLowerCase())) {
cls = (OClassImpl) classes.get(cls.getName().toLowerCase());
cls.fromStream(c);
}
newClasses.put(cls.getName().toLowerCase(), cls);
if (cls.getShortName() != null)
newClasses.put(cls.getShortName().toLowerCase(), cls);
addClusterClassMap(cls);
}
classes.clear();
classes.putAll(newClasses);
// REBUILD THE INHERITANCE TREE
Collection<String> superClassNames;
String legacySuperClassName;
List<OClass> superClasses;
OClass superClass;
for (ODocument c : storedClasses) {
superClassNames = c.field("superClasses");
legacySuperClassName = c.field("superClass");
if (superClassNames == null)
superClassNames = new ArrayList<String>();
else
superClassNames = new HashSet<String>(superClassNames);
if (legacySuperClassName != null && !superClassNames.contains(legacySuperClassName))
superClassNames.add(legacySuperClassName);
if (!superClassNames.isEmpty()) {
// HAS A SUPER CLASS or CLASSES
cls = (OClassImpl) classes.get(((String) c.field("name")).toLowerCase());
superClasses = new ArrayList<OClass>(superClassNames.size());
for (String superClassName : superClassNames) {
superClass = classes.get(superClassName.toLowerCase());
if (superClass == null)
throw new OConfigurationException("Super class '" + superClassName + "' was declared in class '" + cls.getName() + "' but was not found in schema. Remove the dependency or create the class to continue.");
superClasses.add(superClass);
}
cls.setSuperClassesInternal(superClasses);
}
}
if (document.containsField("blobClusters"))
blobClusters = document.field("blobClusters");
if (!hasGlobalProperties) {
if (getDatabase().getStorage().getUnderlying() instanceof OAbstractPaginatedStorage)
saveInternal();
}
} finally {
version++;
modificationCounter.get().decrement();
rwSpinLock.releaseWriteLock();
}
}
use of com.orientechnologies.orient.core.exception.OConfigurationException in project orientdb by orientechnologies.
the class OSocketFactory method createSSLContext.
protected SSLContext createSSLContext() {
try {
if (keyStorePath != null && trustStorePath != null) {
if (keyStorePassword == null || keyStorePassword.equals("")) {
throw new OConfigurationException("Please provide a keystore password");
}
if (trustStorePassword == null || trustStorePassword.equals("")) {
throw new OConfigurationException("Please provide a truststore password");
}
SSLContext context = SSLContext.getInstance("TLS");
KeyManagerFactory kmf = KeyManagerFactory.getInstance(KeyManagerFactory.getDefaultAlgorithm());
KeyStore keyStore = KeyStore.getInstance(keyStoreType);
char[] keyStorePass = keyStorePassword.toCharArray();
keyStore.load(getAsStream(keyStorePath), keyStorePass);
kmf.init(keyStore, keyStorePass);
TrustManagerFactory tmf = null;
if (trustStorePath != null) {
tmf = TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm());
KeyStore trustStore = KeyStore.getInstance(trustStoreType);
char[] trustStorePass = trustStorePassword.toCharArray();
trustStore.load(getAsStream(trustStorePath), trustStorePass);
tmf.init(trustStore);
}
context.init(kmf.getKeyManagers(), (tmf == null ? null : tmf.getTrustManagers()), null);
return context;
} else {
return SSLContext.getDefault();
}
} catch (Exception e) {
throw OException.wrapException(new OConfigurationException("Failed to create ssl context"), e);
}
}
use of com.orientechnologies.orient.core.exception.OConfigurationException in project orientdb by orientechnologies.
the class ODistributedAbstractPlugin method assignNodeName.
protected void assignNodeName() {
// ORIENTDB_NODE_NAME ENV VARIABLE OR JVM SETTING
nodeName = OSystemVariableResolver.resolveVariable(NODE_NAME_ENV);
if (nodeName != null) {
nodeName = nodeName.trim();
if (nodeName.isEmpty())
nodeName = null;
}
if (nodeName == null) {
try {
// WAIT ANY LOG IS PRINTED
Thread.sleep(1000);
} catch (InterruptedException e) {
}
System.out.println();
System.out.println();
System.out.println(OAnsiCode.format("$ANSI{yellow +---------------------------------------------------------------+}"));
System.out.println(OAnsiCode.format("$ANSI{yellow | WARNING: FIRST DISTRIBUTED RUN CONFIGURATION |}"));
System.out.println(OAnsiCode.format("$ANSI{yellow +---------------------------------------------------------------+}"));
System.out.println(OAnsiCode.format("$ANSI{yellow | This is the first time that the server is running as |}"));
System.out.println(OAnsiCode.format("$ANSI{yellow | distributed. Please type the name you want to assign to the |}"));
System.out.println(OAnsiCode.format("$ANSI{yellow | current server node. |}"));
System.out.println(OAnsiCode.format("$ANSI{yellow | |}"));
System.out.println(OAnsiCode.format("$ANSI{yellow | To avoid this message set the environment variable or JVM |}"));
System.out.println(OAnsiCode.format("$ANSI{yellow | setting ORIENTDB_NODE_NAME to the server node name to use. |}"));
System.out.println(OAnsiCode.format("$ANSI{yellow +---------------------------------------------------------------+}"));
System.out.print(OAnsiCode.format("\n$ANSI{yellow Node name [BLANK=auto generate it]: }"));
OConsoleReader reader = new ODefaultConsoleReader();
try {
nodeName = reader.readLine();
} catch (IOException e) {
}
if (nodeName != null) {
nodeName = nodeName.trim();
if (nodeName.isEmpty())
nodeName = null;
}
}
if (nodeName == null)
// GENERATE NODE NAME
this.nodeName = "node" + System.currentTimeMillis();
OLogManager.instance().warn(this, "Assigning distributed node name: %s", this.nodeName);
// SALVE THE NODE NAME IN CONFIGURATION
boolean found = false;
final OServerConfiguration cfg = serverInstance.getConfiguration();
for (OServerHandlerConfiguration h : cfg.handlers) {
if (h.clazz.equals(getClass().getName())) {
for (OServerParameterConfiguration p : h.parameters) {
if (p.name.equals("nodeName")) {
found = true;
p.value = this.nodeName;
break;
}
}
if (!found) {
h.parameters = OArrays.copyOf(h.parameters, h.parameters.length + 1);
h.parameters[h.parameters.length - 1] = new OServerParameterConfiguration("nodeName", this.nodeName);
}
try {
serverInstance.saveConfiguration();
} catch (IOException e) {
throw OException.wrapException(new OConfigurationException("Cannot save server configuration"), e);
}
break;
}
}
}
use of com.orientechnologies.orient.core.exception.OConfigurationException in project orientdb by orientechnologies.
the class OProxyServer method setPorts.
public void setPorts(final String portsAsString) {
ports.clear();
final String[] pairs = portsAsString.split(",");
for (String pair : pairs) {
final String[] fromTo = pair.split("->");
if (fromTo.length != 2)
throw new OConfigurationException("Proxy server: port configuration is not valid. Format: portFrom->portTo");
ports.put(Integer.parseInt(fromTo[0]), Integer.parseInt(fromTo[1]));
}
}
Aggregations