Checks that the service version is compatible with the client.

@param clientVersion the client version
512303
protected void checkVersion(long clientVersion) throws IOException {
    if (mServiceVersion == Constants.UNKNOWN_SERVICE_VERSION) {
      mServiceVersion = getRemoteServiceVersion();
      if (mServiceVersion != clientVersion) {
        throw new IOException(ExceptionMessage.INCOMPATIBLE_VERSION.getMessage(getServiceName(),
            clientVersion, mServiceVersion));
      }
    }
  }
665724
def GetClientVersion(client_id, token=None):
  """"""
  if data_store.RelationalDBEnabled():
    sinfo = data_store.REL_DB.ReadClientStartupInfo(client_id=client_id)
    if sinfo is not None:
      return sinfo.client_info.client_version
    else:
      return config.CONFIG["Source.version_numeric"]
  else:
    with aff4.FACTORY.Open(client_id, token=token) as client:
      cinfo = client.Get(client.Schema.CLIENT_INFO)
      if cinfo is not None:
        return cinfo.client_version
      else:
        return config.CONFIG["Source.version_numeric"]
514509
public static void doMetaCheckVersion(AdminClient adminClient) {
            Map<Properties, List<Integer>> versionsNodeMap = new HashMap<Properties, List<Integer>>();

            for(Integer nodeId: adminClient.getAdminClientCluster().getNodeIds()) {
                Versioned<Properties> versionedProp = doMetaGetVersionsForNode_ExitOnError(adminClient,
                                                                                           nodeId);
                Properties props = versionedProp.getValue();
                if(versionsNodeMap.containsKey(props) == false) {
                    versionsNodeMap.put(props, new ArrayList<Integer>());
                }
                versionsNodeMap.get(props).add(nodeId);
            }

            if(versionsNodeMap.keySet().size() <= 0) {
                System.err.println("No Versions found in the system store... something seriously wrong");
            } else if(versionsNodeMap.keySet().size() == 1) {
                System.err.println("All the nodes have the same metadata versions.");
                printProperties(versionsNodeMap.keySet().iterator().next());
            } else {
                System.err.println("Mismatching versions detected !!! . All are supposed to be written by the same client "
                                   + ""
                                   + " and hence they should exactly match but something different, let us analyze deeper ");
                Map<String, Map<String, List<Integer>>> propertyValueMap = new HashMap<String, Map<String, List<Integer>>>();
                for(Entry<Properties, List<Integer>> entry: versionsNodeMap.entrySet()) {
                    System.out.println("**************************** Node(s): "
                                       + Arrays.toString(entry.getValue().toArray())
                                       + " ****************************");
                    Properties props = entry.getKey();
                    printProperties(props);

                    for(String propName: props.stringPropertyNames()) {
                        String propValue = props.getProperty(propName);

                        if(propertyValueMap.containsKey(propName) == false) {
                            propertyValueMap.put(propName, new HashMap<String, List<Integer>>());
                        }
                        Map<String, List<Integer>> valuetoNodeMap = propertyValueMap.get(propName);
                        if(valuetoNodeMap.containsKey(propValue) == false) {
                            valuetoNodeMap.put(propValue, new ArrayList<Integer>());
                        }
                        valuetoNodeMap.get(propValue).addAll(entry.getValue());
                    }
                }
                
                System.out.println("########## Properties discrepancy report ########");
                for(Entry<String, Map<String, List<Integer>>> entry: propertyValueMap.entrySet()) {
                    Map<String, List<Integer>> valueToNodeMap = entry.getValue();
                    String propName = entry.getKey();
                    List<Integer> allNodeIds = new ArrayList<Integer>();
                    allNodeIds.addAll(adminClient.getAdminClientCluster().getNodeIds());
                    
                    List<Integer> nodesWithValues = new ArrayList<Integer>();
                    if(valueToNodeMap.size() != 1) {
                        System.out.println("Properties with multiple values");
                        for(Entry<String, List<Integer>> valueToNodeEntry: valueToNodeMap
                                                                              .entrySet()) {
                            String propValue = valueToNodeEntry.getKey();
                            nodesWithValues.addAll(valueToNodeEntry.getValue());
                            printProperty(propName, propValue, valueToNodeEntry.getValue());
                        }
                    } else  {
                        Map.Entry<String, List<Integer>> valueToNodeEntry = valueToNodeMap.entrySet()
                                                                                          .iterator()
                                                                                          .next();

                        nodesWithValues.addAll(valueToNodeEntry.getValue());
                        if(nodesWithValues.size() < allNodeIds.size()) {
                            String propValue = valueToNodeEntry.getKey();
                            printProperty(propName, propValue, valueToNodeEntry.getValue());
                        }
                    }

                    allNodeIds.removeAll(nodesWithValues);
                    if(allNodeIds.size() > 0) {
                        System.out.println("The Property " + propName + " is present in the nodes "
                                           + Arrays.toString(nodesWithValues.toArray())
                                           + " but missing from the nodes "
                                           + Arrays.toString(allNodeIds.toArray()));
                    }
                }
            }
        }
1276449
private void initVersion() {
        VersionValues ver = getServiceContext().getRequestVersion();
        VersionValues configVer = getServiceContext().getHttpConfig().getOutgoingVersion();
        if (VersionValues.V10.equals(configVer) && VersionValues.V11.equals(ver)) {
            if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
                Tr.debug(tc, "Configuration forcing 1.0 instead of 1.1");
            }
            setVersion(configVer);
        } else {
            setVersion(ver);
        }
    }
1096699
public static void checkVersions(){
        boolean doCheck = Boolean.parseBoolean(System.getProperty(ND4JSystemProperties.VERSION_CHECK_PROPERTY, "true"));

        if(!doCheck){
            return;
        }

        if(classExists(ND4J_JBLAS_CLASS)) {
            //nd4j-jblas is ancient and incompatible
            log.error("Found incompatible/obsolete backend and version (nd4j-jblas) on classpath. ND4J is unlikely to"
                    + " function correctly with nd4j-jblas on the classpath. JVM will now exit.");
            System.exit(1);
        }

        if(classExists(CANOVA_CLASS)) {
            //Canova is ancient and likely to pull in incompatible dependencies
            log.error("Found incompatible/obsolete library Canova on classpath. ND4J is unlikely to"
                    + " function correctly with this library on the classpath. JVM will now exit.");
            System.exit(1);
        }

        List<VersionInfo> dependencies = getVersionInfos();
        if(dependencies.size() <= 2){
            //No -properties.git files were found on the classpath. This may be due to a misconfigured uber-jar
            // or maybe running in IntelliJ with "dynamic.classpath" set to true (in workspace.xml). Either way,
            // we can't check versions and don't want to log an error, which will more often than not be wrong
            if(dependencies.size() == 0){
                return;
            }

            //Another edge case: no -properties.git files were found, but DL4J and/or DataVec were inferred
            // by class names. If these "inferred by opName" versions were the only things found, we should also
            // not log a warning, as we can't check versions in this case

            boolean dl4jViaClass = false;
            boolean datavecViaClass = false;
            for(VersionInfo vi : dependencies ){
                if(DL4J_GROUPID.equals(vi.getGroupId()) && DL4J_ARTIFACT.equals(vi.getArtifactId())
                        && (UNKNOWN_VERSION.equals(vi.getBuildVersion()))){
                    dl4jViaClass = true;
                } else if(DATAVEC_GROUPID.equals(vi.getGroupId()) && DATAVEC_ARTIFACT.equals(vi.getArtifactId())
                        && (UNKNOWN_VERSION.equals(vi.getBuildVersion()))){
                    datavecViaClass = true;
                }
            }

            if(dependencies.size() == 1 && (dl4jViaClass || datavecViaClass)){
                return;
            } else if(dependencies.size() == 2 && dl4jViaClass && datavecViaClass){
                return;
            }
        }

        Set<String> foundVersions = new HashSet<>();
        for(VersionInfo vi : dependencies){
            String g = vi.getGroupId();
            if(g != null && GROUPIDS_TO_CHECK.contains(g)){
                String version = vi.getBuildVersion();

                if(version.contains("_spark_")){
                    //Normalize spark versions:
                    // "0.9.1_spark_1" to "0.9.1" and "0.9.1_spark_1-SNAPSHOT" to "0.9.1-SNAPSHOT"
                    version = version.replaceAll("_spark_1","");
                    version = version.replaceAll("_spark_2","");
                }

                foundVersions.add(version);
            }
        }

        boolean logVersions = false;

        if(foundVersions.size() > 1){
            log.warn("*** ND4J VERSION CHECK FAILED - INCOMPATIBLE VERSIONS FOUND ***");
            log.warn("Incompatible versions (different version number) of DL4J, ND4J, RL4J, DataVec, Arbiter are unlikely to function correctly");
            logVersions = true;
        }

        //Also: check for mixed scala versions - but only for our dependencies... These are in the artifact ID,
        // scored like dl4j-spack_2.10 and deeplearning4j-ui_2.11
        //And check for mixed spark versions (again, just DL4J/DataVec etc dependencies for now)
        boolean scala210 = false;
        boolean scala211 = false;
        boolean spark1 = false;
        boolean spark2 = false;
        for(VersionInfo vi : dependencies){
            String artifact = vi.getArtifactId();
            if(!scala210 && artifact.contains(SCALA_210_SUFFIX)){
                scala210 = true;
            }
            if(!scala211 && artifact.contains(SCALA_211_SUFFIX)){
                scala211 = true;
            }

            String version = vi.getBuildVersion();
            if(!spark1 && version.contains(SPARK_1_VER_STRING)){
                spark1 = true;
            }
            if(!spark2 && version.contains(SPARK_2_VER_STRING)){
                spark2 = true;
            }
        }

        if(scala210 && scala211){
            log.warn("*** ND4J VERSION CHECK FAILED - FOUND BOTH SCALA VERSION 2.10 AND 2.11 ARTIFACTS ***");
            log.warn("Projects with mixed Scala versions (2.10/2.11) are unlikely to function correctly");
            logVersions = true;
        }

        if(spark1 && spark2){
            log.warn("*** ND4J VERSION CHECK FAILED - FOUND BOTH SPARK VERSION 1 AND 2 ARTIFACTS ***");
            log.warn("Projects with mixed Spark versions (1 and 2) are unlikely to function correctly");
            logVersions = true;
        }

        if(logVersions){
            log.info("Versions of artifacts found on classpath:");
            logVersionInfo();
        }
    }
626940
@Override
    public String getVersion() throws ConnectionException {
        return connectionPool.executeWithFailover(
                new AbstractOperationImpl<String>(tracerFactory.newTracer(CassandraOperationType.GET_VERSION)) {
                    @Override
                    public String internalExecute(Client client, ConnectionContext state) throws Exception {
                        return client.describe_version();
                    }
                }, config.getRetryPolicy().duplicate()).getResult();
    }
647778
public long getProtocolVersion(String protocol,
                                 long clientVersion) throws IOException {
    if (protocol.equals(AvatarProtocol.class.getName())) {
      return AvatarProtocol.versionID;
    } else {
      return super.getProtocolVersion(protocol, clientVersion);
    } 
  }
813638
public boolean validateVersionType(String versionType, DiagnosticChain diagnostics, Map<Object, Object> context) {
		return true;
	}
344225
public boolean match( Artifact artifact )
        throws InvalidVersionSpecificationException
    {
        for ( Pattern pattern : patterns )
        {
            if ( pattern.match( artifact ) )
            {
                for ( Pattern ignorePattern : ignorePatterns )
                {
                    if ( ignorePattern.match( artifact ) )
                    {
                        return false;
                    }
                }
                return true;
            }
        }
        return false;
    }
1371897
public static void checkVersionUpgradable(int oldVersion) 
                                     throws IOException {
    if (oldVersion > LAST_UPGRADABLE_LAYOUT_VERSION) {
      String msg = "*********** Upgrade is not supported from this older" +
                   " version of storage to the current version." + 
                   " Please upgrade to " + LAST_UPGRADABLE_HADOOP_VERSION +
                   " or a later version and then upgrade to current" +
                   " version. Old layout version is " + 
                   (oldVersion == 0 ? "'too old'" : (""+oldVersion)) +
                   " and latest layout version this software version can" +
                   " upgrade from is " + LAST_UPGRADABLE_LAYOUT_VERSION +
                   ". ************";
      LOG.error(msg);
      throw new IOException(msg); 
    }
    
  }
371691
@GET
  @Path("/check")
  @Produces(APPLICATION_JSON)
  @Timed
  @ExceptionMetered
  public VersionCheckResponse versionCheck(
      @QueryParam("client") @DefaultValue("") final String client) {
    final PomVersion serverVersion = PomVersion.parse(Version.POM_VERSION);
    final VersionCompatibility.Status status;

    if (isNullOrEmpty(client)) {
      return new VersionCheckResponse(VersionCompatibility.Status.MISSING,
          serverVersion, Version.RECOMMENDED_VERSION);
    }

    final PomVersion clientVersion = PomVersion.parse(client);
    status = VersionCompatibility.getStatus(serverVersion, clientVersion);
    return new VersionCheckResponse(status, serverVersion, Version.RECOMMENDED_VERSION);
  }
148822
public boolean isCompatibleWith(String runtimeVersion) {
    if (null == this.minimalSqVersion) {
      // no constraint defined on the plugin
      return true;
    }

    Version effectiveMin = Version.create(minimalSqVersion.getName()).removeQualifier();
    Version effectiveVersion = Version.create(runtimeVersion).removeQualifier();

    if (runtimeVersion.endsWith("-SNAPSHOT")) {
      // check only the major and minor versions (two first fields)
      effectiveMin = Version.create(effectiveMin.getMajor() + "." + effectiveMin.getMinor());
    }

    return effectiveVersion.compareTo(effectiveMin) >= 0;
  }
1225452
public static final ApiVersionAlreadyExistsException apiVersionAlreadyExistsException(String apiName, String version) {
        return new ApiVersionAlreadyExistsException(Messages.i18n.format("ApiVersionAlreadyExists", apiName, version)); //$NON-NLS-1$
    }
151718
public static boolean checkIfClassVersionApplicable(Object cacheEntry, boolean useStructuredCache) {
        if (!useStructuredCache && cacheEntry instanceof CacheEntry) {
            return true;
        }

        if (useStructuredCache && cacheEntry instanceof Map) {
            return true;
        }
        return false;
    }
1298992
public static boolean isAtLeast(String version, String requiredVersion) {
        if (version != null) {
            SemanticVersion thisVersion = new SemanticVersion(version);
            SemanticVersion otherVersion = new SemanticVersion(requiredVersion);
            return thisVersion.compareTo(otherVersion) != -1;
        }
        return false;
    }
469439
@SuppressWarnings({"boxing"})
    public boolean checkOceeVersion(String version) {

        try {
            Class<?> manager = Class.forName("org.opencms.ocee.base.CmsOceeManager");
            Method checkVersion = manager.getMethod("checkOceeVersion", String.class);
            return (Boolean)checkVersion.invoke(manager, version);
        } catch (@SuppressWarnings("unused") ClassNotFoundException e) {
            return true;
        } catch (Exception e) {
            e.printStackTrace();
            return false;
        }
    }
938329
public static boolean isCatalogCompatible(String catalogVersionStr)
    {
        if (catalogVersionStr == null || catalogVersionStr.isEmpty()) {
            return false;
        }

        //Check that it is a properly formed verstion string
        Object[] catalogVersion = MiscUtils.parseVersionString(catalogVersionStr);
        if (catalogVersion == null) {
            throw new IllegalArgumentException("Invalid version string " + catalogVersionStr);
        }

        if (!catalogVersionStr.equals(VoltDB.instance().getVersionString())) {
            return false;
        }

        return true;
    }