Validate store schema -- backward compatibility if it is AVRO generic
versioned -- sanity checks for avro in general

@param storeDefinition the store definition to check on
16194
public static void validateSchemaAsNeeded(StoreDefinition storeDefinition) {
        logger.info("Validating schema for store: " + storeDefinition.getName());
        SerializerDefinition keySerDef = storeDefinition.getKeySerializer();
        // validate the key schemas
        try {
            validateIfAvroSchema(keySerDef);
        } catch(Exception e) {
            logger.error("Validating key schema failed for store:  " + storeDefinition.getName());
            throw new VoldemortException("Error validating key schema for store:  "
                                         + storeDefinition.getName() + " " + e.getMessage(), e);
        }

        // validate the value schemas
        SerializerDefinition valueSerDef = storeDefinition.getValueSerializer();
        try {
            validateIfAvroSchema(valueSerDef);
        } catch(Exception e) {
            logger.error("Validating value schema failed for store:  " + storeDefinition.getName());
            throw new VoldemortException("Error validating value schema for store:  "
                                         + storeDefinition.getName() + " " + e.getMessage(), e);
        }
    }
1021823
private StoredDatabaseInfo registerPrimaryDatabase(boolean readOnly, Layout layout)
        throws Exception
    {
        if (getStorableType() == StoredDatabaseInfo.class) {
            // Can't register itself in itself.
            return null;
        }

        Repository repo = mRepository.getRootRepository();

        StoredDatabaseInfo info;
        try {
            info = repo.storageFor(StoredDatabaseInfo.class).prepare();
        } catch (SupportException e) {
            return null;
        }
        info.setDatabaseName(getStorableType().getName());

        // Try to insert metadata up to three times.
        boolean top = true;
        for (int retryCount = 3;;) {
            try {
                Transaction txn;
                if (top) {
                    txn = repo.enterTopTransaction(IsolationLevel.READ_COMMITTED);
                } else {
                    txn = repo.enterTransaction(IsolationLevel.READ_COMMITTED);
                }

                txn.setForUpdate(true);
                try {
                    if (!info.tryLoad()) {
                        if (layout == null) {
                            info.setEvolutionStrategy(StoredDatabaseInfo.EVOLUTION_NONE);
                        } else {
                            info.setEvolutionStrategy(StoredDatabaseInfo.EVOLUTION_STANDARD);
                        }
                        info.setCreationTimestamp(System.currentTimeMillis());
                        info.setVersionNumber(0);
                        if (!readOnly) {
                            info.insert();
                        }
                    }
                    txn.commit();
                } finally {
                    txn.exit();
                }
                break;
            } catch (UniqueConstraintException e) {
                // This might be caused by a transient replication error. Retry
                // a few times before throwing exception. Wait up to a second
                // before each retry.
                retryCount = e.backoff(e, retryCount, 1000);
            } catch (FetchException e) {
                if (e instanceof FetchDeadlockException || e instanceof FetchTimeoutException) {
                    // Might be caused by coarse locks. Switch to nested
                    // transaction to share the locks.
                    if (top) {
                        top = false;
                        retryCount = e.backoff(e, retryCount, 100);
                        continue;
                    }
                }
                throw e;
            } catch (PersistException e) {
                if (e instanceof PersistDeadlockException || e instanceof PersistTimeoutException){
                    // Might be caused by coarse locks. Switch to nested
                    // transaction to share the locks.
                    if (top) {
                        top = false;
                        retryCount = e.backoff(e, retryCount, 100);
                        continue;
                    }
                }
                throw e;
            }
        }

        return info;
    }
7178
private HashMap<String, StoreDefinition> makeStoreDefinitionMap(List<StoreDefinition> storeDefs) {
        HashMap<String, StoreDefinition> storeDefMap = new HashMap<String, StoreDefinition>();
        for(StoreDefinition storeDef: storeDefs)
            storeDefMap.put(storeDef.getName(), storeDef);
        return storeDefMap;
    }
803360
@Override
    public void deleteStoreIfPresent(String storeName) {
        String tableName = storeToCQLName(storeName);
        if (storeExists(tableName)) {
            new CQLSchemaManager(this).dropCQLTable(tableName);
        }
    }
582284
@Override
    public void createStoreIfAbsent(String storeName, boolean bBinaryValues) {
        DBConn dbConn = getDBConnection();
        try {
            synchronized (m_schemaLock) {
                if (!m_schemaMgr.columnFamilyExists(dbConn, m_keyspace, storeName)) {
                    m_schemaMgr.createColumnFamily(dbConn, m_keyspace, storeName, bBinaryValues);
                }
            }
        } finally {
            returnDBConnection(dbConn);
        }
    }
477186
private void verifyOrAddStore(String clusterURL,
                                  String keySchema,
                                  String valueSchema) {
        String newStoreDefXml = VoldemortUtils.getStoreDefXml(
                storeName,
                props.getInt(BUILD_REPLICATION_FACTOR, 2),
                props.getInt(BUILD_REQUIRED_READS, 1),
                props.getInt(BUILD_REQUIRED_WRITES, 1),
                props.getNullableInt(BUILD_PREFERRED_READS),
                props.getNullableInt(BUILD_PREFERRED_WRITES),
                props.getString(PUSH_FORCE_SCHEMA_KEY, keySchema),
                props.getString(PUSH_FORCE_SCHEMA_VALUE, valueSchema),
                description,
                owners);

        log.info("Verifying store against cluster URL: " + clusterURL + "\n" + newStoreDefXml.toString());
        StoreDefinition newStoreDef = VoldemortUtils.getStoreDef(newStoreDefXml);

        try {
            adminClientPerCluster.get(clusterURL).storeMgmtOps.verifyOrAddStore(newStoreDef, "BnP config/data",
                enableStoreCreation, this.storeVerificationExecutorService);
        } catch (UnreachableStoreException e) {
            log.info("verifyOrAddStore() failed on some nodes for clusterURL: " + clusterURL + " (this is harmless).", e);
            // When we can't reach some node, we just skip it and won't create the store on it.
            // Next time BnP is run while the node is up, it will get the store created.
        } // Other exceptions need to bubble up!

        storeDef = newStoreDef;
    }
146085
function(definition, client) {

  this.client = client;

  this.schema = null;

  this.ddlHelper = {
    tableName: null,
    pkAttrName: null,
    pkAutoIncrement: false,
    attrNamesToColNames: {},
    attrTypes: {},
    colNamesToAttrNames: {},
    colTypes: {},
    defaultValues: {},
    cqlCreateTable: null,
    indexes: {}
  };

  this._parseDefinition(definition);
}
1152316
@Override
    public void initializeApplication(ApplicationDefinition oldAppDef,
                                      ApplicationDefinition appDef) {
        checkServiceState();
        OLAPService.instance().initializeApplication(oldAppDef, appDef);
    }
1295899
private void verifyClusterStoreDefinition() {
        if(SystemStoreConstants.isSystemStore(storeDefinition.getName())) {
            // TODO: Once "todo" in StorageService.initSystemStores is complete,
            // this early return can be removed and verification can be enabled
            // for system stores.
            return;
        }

        Set<Integer> clusterZoneIds = cluster.getZoneIds();

        if(clusterZoneIds.size() > 1) { // Zoned
            Map<Integer, Integer> zoneRepFactor = storeDefinition.getZoneReplicationFactor();
            Set<Integer> storeDefZoneIds = zoneRepFactor.keySet();

            if(!clusterZoneIds.equals(storeDefZoneIds)) {
                throw new VoldemortException("Zone IDs in cluster (" + clusterZoneIds
                                             + ") are incongruent with zone IDs in store defs ("
                                             + storeDefZoneIds + ")");
            }

            for(int zoneId: clusterZoneIds) {
                if(zoneRepFactor.get(zoneId) > cluster.getNumberOfNodesInZone(zoneId)) {
                    throw new VoldemortException("Not enough nodes ("
                                                 + cluster.getNumberOfNodesInZone(zoneId)
                                                 + ") in zone with id " + zoneId
                                                 + " for replication factor of "
                                                 + zoneRepFactor.get(zoneId) + ".");
                }
            }
        } else { // Non-zoned

            if(storeDefinition.getReplicationFactor() > cluster.getNumberOfNodes()) {
                System.err.println(storeDefinition);
                System.err.println(cluster);
                throw new VoldemortException("Not enough nodes (" + cluster.getNumberOfNodes()
                                             + ") for replication factor of "
                                             + storeDefinition.getReplicationFactor() + ".");
            }
        }
    }
979061
protected void initValid(EnhancedAnnotation<T> annotatedAnnotation) {
        this.valid = false;
        for (Class<? extends Annotation> annotationType : getMetaAnnotationTypes()) {
            if (annotatedAnnotation.isAnnotationPresent(annotationType)) {
                this.valid = true;
            }
        }
    }
1062285
public static void validateUserStoreNamesOnNode(AdminClient adminClient,
                                                    Integer nodeId,
                                                    List<String> storeNames) {
        List<StoreDefinition> storeDefList = adminClient.metadataMgmtOps.getRemoteStoreDefList(nodeId)
                                                                        .getValue();
        Map<String, Boolean> existingStoreNames = new HashMap<String, Boolean>();
        for(StoreDefinition storeDef: storeDefList) {
            existingStoreNames.put(storeDef.getName(), true);
        }
        for(String storeName: storeNames) {
            if(!Boolean.TRUE.equals(existingStoreNames.get(storeName))) {
                Utils.croak("Store " + storeName + " does not exist!");
            }
        }
    }
142036
public TypeDefinitionRegistry parse(Reader reader) throws SchemaProblem {
        try (Reader input = reader) {
            return parseImpl(input);
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }
646069
protected void checkReferenceable(ImportNodeData currentNodeInfo, String olUuid) throws RepositoryException
   {
      // if node is in version storage - do not assign new id from jcr:uuid
      // property
      if (Constants.JCR_VERSION_STORAGE_PATH.getDepth() + 3 <= currentNodeInfo.getQPath().getDepth()
         && currentNodeInfo.getQPath().getEntries()[Constants.JCR_VERSION_STORAGE_PATH.getDepth() + 3]
            .equals(Constants.JCR_FROZENNODE)
         && currentNodeInfo.getQPath().isDescendantOf(Constants.JCR_VERSION_STORAGE_PATH))
      {
         return;
      }

      String identifier = validateUuidCollision(olUuid);

      if (identifier != null)
      {
         reloadChangesInfoAfterUC(currentNodeInfo, identifier);
      }
      else
      {
         currentNodeInfo.setIsNewIdentifer(true);
      }
      if (uuidBehavior == ImportUUIDBehavior.IMPORT_UUID_COLLISION_REPLACE_EXISTING)
      {
         NodeData parentNode = getParent();
         currentNodeInfo.setParentIdentifer(parentNode.getIdentifier());
         if (parentNode instanceof ImportNodeData && ((ImportNodeData)parentNode).isTemporary())
         {
            // remove the temporary parent
            tree.pop();
         }
      }
   }
236393
private void registerJsfCdiToSpring(BeanDefinition definition) {

		if (definition instanceof AnnotatedBeanDefinition) {
			AnnotatedBeanDefinition annDef = (AnnotatedBeanDefinition) definition;

			String scopeName = null;
			// firstly check whether bean is defined via configuration
			if (annDef.getFactoryMethodMetadata() != null) {
				scopeName = deduceScopeName(annDef.getFactoryMethodMetadata());
			}
			else {
				// fallback to type
				scopeName = deduceScopeName(annDef.getMetadata());
			}

			if (scopeName != null) {
				definition.setScope(scopeName);

				log.debug("{} - Scope({})", definition.getBeanClassName(), scopeName.toUpperCase());
			}
		}
	}
1179748
public void addStructureDefinition(StructureDefinition theStructureDefinition) {
		Validate.notBlank(theStructureDefinition.getUrl(), "theStructureDefinition.getUrl() must not return a value");
		myStructureDefinitions.put(theStructureDefinition.getUrl(), theStructureDefinition);
	}
43620
private void checkObjectImplementsInterface(GraphQLObjectType objectType, GraphQLInterfaceType interfaceType, SchemaValidationErrorCollector validationErrorCollector) {
        List<GraphQLFieldDefinition> fieldDefinitions = interfaceType.getFieldDefinitions();
        for (GraphQLFieldDefinition interfaceFieldDef : fieldDefinitions) {
            GraphQLFieldDefinition objectFieldDef = objectType.getFieldDefinition(interfaceFieldDef.getName());
            if (objectFieldDef == null) {
                validationErrorCollector.addError(
                        error(format("object type '%s' does not implement interface '%s' because field '%s' is missing",
                                objectType.getName(), interfaceType.getName(), interfaceFieldDef.getName())));
            } else {
                checkFieldTypeCompatibility(objectType, interfaceType, validationErrorCollector, interfaceFieldDef, objectFieldDef);
            }
        }
    }
1363083
@Override
  public void updateModifiableFieldsFromEntity(DecisionDefinitionEntity updatingDecisionDefinition) {
    if (this.key.equals(updatingDecisionDefinition.key) && this.deploymentId.equals(updatingDecisionDefinition.deploymentId)) {
      this.revision = updatingDecisionDefinition.revision;
      this.historyTimeToLive = updatingDecisionDefinition.historyTimeToLive;
    } else {
      LOG.logUpdateUnrelatedDecisionDefinitionEntity(this.key, updatingDecisionDefinition.key, this.deploymentId, updatingDecisionDefinition.deploymentId);
    }
  }