Refine search
private List<OResult> toResult(Collection<? extends OCluster> clusterInstances) { List<OResult> result = new ArrayList<>(); if (clusterInstances != null) { for (OCluster cluster : clusterInstances) { OResultInternal item = new OResultInternal(); item.setProperty("name", cluster.getName()); item.setProperty("fileName", cluster.getFileName()); item.setProperty("id", cluster.getId()); item.setProperty("entries", cluster.getEntries()); item.setProperty("conflictStrategy", cluster.getRecordConflictStrategy() == null ? null : cluster.getRecordConflictStrategy().getName()); item.setProperty("tombstonesCount", cluster.getTombstonesCount()); try { item.setProperty("encryption", cluster.encryption()); } catch (Exception e) { OLogManager.instance().error(this, "Can not set value of encryption parameter", e); } result.add(item); } } return result; }
/** * Enables password-based-encryption for records of the given type. * * Can only be called when creating the schema. * * @since 3.1 */ protected void enableRecordEncryption(final ODatabaseDocumentTx db, final OClass type) { OStorage storage = db.getStorage(); for (int clusterId : type.getClusterIds()) { OCluster cluster = storage.getClusterById(clusterId); try { log.debug("Enabling PBE compression for cluster: {}", cluster.getName()); cluster.set(OCluster.ATTRIBUTES.COMPRESSION, PbeCompression.NAME); } catch (IOException e) { throw new RuntimeException(e); } catch (IllegalArgumentException | OStorageException | OSecurityException e) { log.warn("Cannot enable PBE compression for cluster: {}", cluster.getName(), e); } } }
@Override public long getClusterRecordSizeById(final int clusterId) { checkIfActive(); try { return getStorage().getClusterById(clusterId).getRecordsSize(); } catch (Exception e) { throw OException .wrapException(new ODatabaseException("Error on reading records size for cluster with id '" + clusterId + "'"), e); } }
@Override public long countRecords() { long tot = 0; for (OCluster c : getClusterInstances()) if (c != null) tot += c.getEntries() - c.getTombstonesCount(); return tot; }
@SuppressWarnings("unchecked") @Override protected V getValue(OCluster entity, String critery) { if(OClustersWidget.CONFLICT_STRATEGY.equals(critery)) { ORecordConflictStrategy strategy = entity.getRecordConflictStrategy(); return (V)(strategy!=null?strategy.getName():null); } else if(OClustersWidget.COMPRESSION.equals(critery)) { return (V)entity.compression(); } else { return (V) PropertyResolver.getValue(critery, entity); } }
/** * Execute the command. */ public Object execute(final Map<Object, Object> iArgs) { if (clusterName == null) throw new OCommandExecutionException("Cannot execute the command because it has not been parsed yet"); final ODatabaseDocumentInternal database = getDatabase(); final int clusterId = database.getClusterIdByName(clusterName); if (clusterId < 0) { throw new ODatabaseException("Cluster with name " + clusterName + " does not exist"); } final OSchema schema = database.getMetadata().getSchema(); final OClass clazz = schema.getClassByClusterId(clusterId); if (clazz == null) { final OStorage storage = database.getStorage(); final OCluster cluster = storage.getClusterById(clusterId); if (cluster == null) { throw new ODatabaseException("Cluster with name " + clusterName + " does not exist"); } try { database.checkForClusterPermissions(cluster.getName()); cluster.truncate(); } catch (IOException ioe) { throw OException.wrapException(new ODatabaseException("Error during truncation of cluster with name " + clusterName), ioe); } } else { clazz.truncateCluster(clusterName); } return true; }
cluster.close(true); newCluster = new OOfflineCluster(this, clusterId, cluster.getName()); if (clusterConfiguration.getId() == cluster.getId()) { newCluster.configure(this, clusterConfiguration); configured = true; break; .createCluster(cluster.getName(), configuration.getVersion(), cluster.getBinaryVersion(), this); newCluster.configure(this, clusterId, cluster.getName()); newCluster.open(); clusterMap.put(cluster.getName().toLowerCase(configuration.getLocaleInstance()), newCluster); clusters.set(clusterId, newCluster); return true; } catch (final Exception e) { throw OException.wrapException(new OStorageException("Error while removing cluster '" + clusterId + "'"), e); } finally { stateLock.releaseWriteLock();
/** * Execute the ALTER CLASS. */ public Object execute(final Map<Object, Object> iArgs) { if (attribute == null) throw new OCommandExecutionException("Cannot execute the command because it has not been parsed yet"); final List<OCluster> clusters = getClusters(); if (clusters.isEmpty()) throw new OCommandExecutionException("Cluster '" + clusterName + "' not found"); Object result = null; for (OCluster cluster : getClusters()) { if (clusterId > -1 && clusterName.equals(String.valueOf(clusterId))) { clusterName = cluster.getName(); } else { clusterId = cluster.getId(); } try { if (attribute == ATTRIBUTES.STATUS && OStorageClusterConfiguration.STATUS.OFFLINE.toString().equalsIgnoreCase(value)) // REMOVE CACHE OF COMMAND RESULTS IF ACTIVE getDatabase().getMetadata().getCommandCache().invalidateResultsOfCluster(clusterName); if (attribute == ATTRIBUTES.NAME) // REMOVE CACHE OF COMMAND RESULTS IF ACTIVE getDatabase().getMetadata().getCommandCache().invalidateResultsOfCluster(clusterName); result = cluster.set(attribute, value); } catch (IOException ioe) { throw OException.wrapException(new OCommandExecutionException("Error altering cluster '" + clusterName + "'"), ioe); } } return result; }
@Override public OResultSet executeDDL(OCommandContext ctx) { OInternalResultSet result = new OInternalResultSet(); List<com.orientechnologies.orient.core.storage.OCluster> clustersToUpdate = getClusters(ctx); Object finalValue = attributeValue.execute((OIdentifiable) null, ctx); com.orientechnologies.orient.core.storage.OCluster.ATTRIBUTES attribute; try { attribute = OCluster.ATTRIBUTES.valueOf(attributeName.getStringValue()); } catch (IllegalArgumentException e) { throw OException.wrapException(new OCommandExecutionException( "Unknown class attribute '" + attributeName + "'. Supported attributes are: " + Arrays .toString(OCluster.ATTRIBUTES.values())), e); } for (com.orientechnologies.orient.core.storage.OCluster cluster : clustersToUpdate) { if (attributeName.getStringValue().equalsIgnoreCase("status") || attributeName.getStringValue().equalsIgnoreCase("name")) // REMOVE CACHE OF COMMAND RESULTS IF ACTIVE getDatabase().getMetadata().getCommandCache().invalidateResultsOfCluster(cluster.getName()); try { cluster.set(attribute, finalValue); } catch (IOException e) { OException.wrapException(new OCommandExecutionException("Cannot execute alter cluster"), e); } OResultInternal resultItem = new OResultInternal(); resultItem.setProperty("cluster", cluster.getName()); result.add(resultItem); } return result; }
cluster.truncate(); cluster.delete(); clusterMap.remove(cluster.getName().toLowerCase(configuration.getLocaleInstance())); clusters.set(clusterId, null); throw OException.wrapException(new OStorageException("Error while removing cluster '" + clusterId + "'"), e);
final boolean isRemote = currentDatabase.getStorage().isRemote(); final OCluster cluster = currentDatabase.getStorage().getClusterById(clusterId); cluster.getRecordConflictStrategy() != null ? cluster.getRecordConflictStrategy().getName() : ""; final long spaceUsed = !isRemote ? cluster.getRecordsSize() : 0; totalSpaceUsed += spaceUsed; final long tombstones = !isRemote ? cluster.getTombstonesCount() : 0; totalTombstones += tombstones; row.field("ID", clusterId); row.field("CLASS", className); if (!currentDatabase.getStorage().isRemote()) { row.field("CONFLICT-STRATEGY", conflictStrategy);
try { final OPhysicalPosition ppos = cluster.getPhysicalPosition(new OPhysicalPosition(rid.getClusterPosition())); if (!checkForRecordValidity(ppos)) { final int recordVersion = -1; try { if (updateContent) { cluster.updateRecord(rid.getClusterPosition(), content, ppos.recordVersion, recordType); OLogManager.instance().error(this, "Error on updating record " + rid + " (cluster: " + cluster + ")", e); throw OException .wrapException(new OStorageException("Error on updating record " + rid + " (cluster: " + cluster.getName() + ")"), e); } finally { atomicOperationsManager.endAtomicOperation(rollback); } catch (final IOException ioe) { throw OException .wrapException(new OStorageException("Error on updating record " + rid + " (cluster: " + cluster.getName() + ")"), ioe);
try { final OPhysicalPosition ppos = cluster.getPhysicalPosition(new OPhysicalPosition(rid.getClusterPosition())); atomicOperationsManager.startAtomicOperation((String) null, true); try { cluster.deleteRecord(ppos.clusterPosition); } catch (final IOException ioe) { throw OException .wrapException(new OStorageException("Error on deleting record " + rid + "( cluster: " + cluster.getName() + ")"), ioe);
private String getSecurityResourceSpecific() { return OClusterSecurityWidget.this.getModelObject().getName(); } };
OPhysicalPosition ppos; try { ppos = cluster.createRecord(content, recordVersion, recordType, allocated); rid.setClusterPosition(ppos.clusterPosition); throw OException.wrapException( new OStorageException("Error during record deletion in cluster " + (cluster != null ? cluster.getName() : "")), ioe);
"Requested cluster ID [" + requestedId + "] is occupied by cluster with name [" + clusters.get(requestedId).getName() + "]"); throw OException.wrapException(new OStorageException("Error in creation of new cluster '" + clusterName + "'"), e); } finally { stateLock.releaseWriteLock();
OCluster cl = storage.getClusterById(id); db.checkForClusterPermissions(cl.getName()); cl.truncate();
@Override public final long[] getClusterDataRange(final int iClusterId) { try { if (iClusterId == -1) { return new long[] { ORID.CLUSTER_POS_INVALID, ORID.CLUSTER_POS_INVALID }; } checkOpenness(); stateLock.acquireReadLock(); try { checkOpenness(); return clusters.get(iClusterId) != null ? new long[] { clusters.get(iClusterId).getFirstPosition(), clusters.get(iClusterId).getLastPosition() } : OCommonConst.EMPTY_LONG_ARRAY; } catch (final IOException ioe) { throw OException.wrapException(new OStorageException("Cannot retrieve information about data range"), ioe); } finally { stateLock.releaseReadLock(); } } catch (final RuntimeException ee) { throw logAndPrepareForRethrow(ee); } catch (final Error ee) { throw logAndPrepareForRethrow(ee); } catch (final Throwable t) { throw logAndPrepareForRethrow(t); } }
final String inField = OrientEdgeType.CLASS_NAME.equals(edgeClass) ? "in_" : ("in_" + edgeClass); String clusterName = perThreadDbInstance.getStorage().getClusterById(clusterId).getName();
/** * Register the cluster internally. * * @param cluster OCluster implementation * * @return The id (physical position into the array) of the new cluster just created. First is 0. */ private int registerCluster(final OCluster cluster) { final int id; if (cluster != null) { // CHECK FOR DUPLICATION OF NAMES if (clusterMap.containsKey(cluster.getName().toLowerCase(configuration.getLocaleInstance()))) { throw new OConfigurationException( "Cannot add cluster '" + cluster.getName() + "' because it is already registered in database '" + name + "'"); } // CREATE AND ADD THE NEW REF SEGMENT clusterMap.put(cluster.getName().toLowerCase(configuration.getLocaleInstance()), cluster); id = cluster.getId(); } else { id = clusters.size(); } setCluster(id, cluster); return id; }