@Override public SerializationServiceBuilder setVersion(byte version) { byte maxVersion = BuildInfoProvider.getBuildInfo().getSerializationVersion(); if (version > maxVersion) { throw new IllegalArgumentException( "Configured serialization version is higher than the max supported version: " + maxVersion); } this.version = version; return this; }
private static BuildInfo populateBuildInfoCache() { return getBuildInfoInternalVersion(Overrides.DISABLED); }
private static BuildInfo getBuildInfoInternalVersion(Overrides overrides) { // If you have a compilation error at GeneratedBuildProperties then run 'mvn clean install' // the GeneratedBuildProperties class is generated at a compile-time BuildInfo buildInfo = readBuildPropertiesClass(GeneratedBuildProperties.class, null, overrides); try { Class<?> enterpriseClass = BuildInfoProvider.class.getClassLoader() .loadClass("com.hazelcast.instance.GeneratedEnterpriseBuildProperties"); if (enterpriseClass.getClassLoader() == BuildInfoProvider.class.getClassLoader()) { //only read the enterprise properties if there were loaded by the same classloader //as BuildInfoProvider and not e.g. a parent classloader. buildInfo = readBuildPropertiesClass(enterpriseClass, buildInfo, overrides); } } catch (ClassNotFoundException e) { ignore(e); } Properties jetProperties = loadPropertiesFromResource("jet-runtime.properties"); return withJetProperties(jetProperties, buildInfo); }
private static BuildInfo readBuildPropertiesClass(Class<?> clazz, BuildInfo upstreamBuildInfo, Overrides overrides) { String version = readStaticStringField(clazz, "VERSION"); String build = readStaticStringField(clazz, "BUILD"); String revision = readStaticStringField(clazz, "REVISION"); String distribution = readStaticStringField(clazz, "DISTRIBUTION"); if (!revision.isEmpty() && revision.equals("${git.commit.id.abbrev}")) { revision = ""; } int buildNumber = Integer.parseInt(build); boolean enterprise = !"Hazelcast".equals(distribution); String serialVersionString = readStaticStringField(clazz, "SERIALIZATION_VERSION"); byte serialVersion = Byte.parseByte(serialVersionString); return overrides.apply(version, build, revision, buildNumber, enterprise, serialVersion, upstreamBuildInfo); }
private static BuildInfo readBuildPropertiesClass(Class<?> clazz, BuildInfo upstreamBuildInfo, Overrides overrides) { String version = readStaticStringField(clazz, "VERSION"); String build = readStaticStringField(clazz, "BUILD"); String revision = readStaticStringField(clazz, "REVISION"); String distribution = readStaticStringField(clazz, "DISTRIBUTION"); if (!revision.isEmpty() && revision.equals("${git.commit.id.abbrev}")) { revision = ""; } int buildNumber = Integer.parseInt(build); boolean enterprise = !"Hazelcast".equals(distribution); String serialVersionString = readStaticStringField(clazz, "SERIALIZATION_VERSION"); byte serialVersion = Byte.parseByte(serialVersionString); return overrides.apply(version, build, revision, buildNumber, enterprise, serialVersion, upstreamBuildInfo); }
/** * Throws {@link IllegalArgumentException} if the given {@link InMemoryFormat} * is {@link InMemoryFormat#NATIVE} and Hazelcast is OS. * * @param inMemoryFormat supplied inMemoryFormat */ private static void checkNotNativeWhenOpenSource(InMemoryFormat inMemoryFormat) { if (inMemoryFormat == NATIVE && !getBuildInfo().isEnterprise()) { throw new IllegalArgumentException("NATIVE storage format is supported in Hazelcast Enterprise only." + " Make sure you have Hazelcast Enterprise JARs on your classpath!"); } }
private static BuildInfo getBuildInfoInternalVersion(Overrides overrides) { // If you have a compilation error at GeneratedBuildProperties then run 'mvn clean install' // the GeneratedBuildProperties class is generated at a compile-time BuildInfo buildInfo = readBuildPropertiesClass(GeneratedBuildProperties.class, null, overrides); try { Class<?> enterpriseClass = BuildInfoProvider.class.getClassLoader() .loadClass("com.hazelcast.instance.GeneratedEnterpriseBuildProperties"); if (enterpriseClass.getClassLoader() == BuildInfoProvider.class.getClassLoader()) { //only read the enterprise properties if there were loaded by the same classloader //as BuildInfoProvider and not e.g. a parent classloader. buildInfo = readBuildPropertiesClass(enterpriseClass, buildInfo, overrides); } } catch (ClassNotFoundException e) { ignore(e); } Properties jetProperties = loadPropertiesFromResource("jet-runtime.properties"); return withJetProperties(jetProperties, buildInfo); }
private static BuildInfo populateBuildInfoCache() { return getBuildInfoInternalVersion(Overrides.DISABLED); }
@Override public SerializationServiceBuilder setVersion(byte version) { byte maxVersion = BuildInfoProvider.getBuildInfo().getSerializationVersion(); if (version > maxVersion) { throw new IllegalArgumentException( "Configured serialization version is higher than the max supported version: " + maxVersion); } this.version = version; return this; }
/** * Parses {@code hazelcast-runtime.properties} for {@code BuildInfo}; also checks for overrides in System.properties. * Never cache result of this method in a static context - as it can change due versions overriding - this method * already does caching whenever it's possible - i.e. when overrides is disabled. * * @return the parsed BuildInfo */ public static BuildInfo getBuildInfo() { if (Overrides.isEnabled()) { // never use cache when override is enabled -> we need to re-parse everything Overrides overrides = Overrides.fromProperties(); return getBuildInfoInternalVersion(overrides); } return BUILD_INFO_CACHE; }
/** * Throws {@link IllegalArgumentException} if the given {@link InMemoryFormat} * is {@link InMemoryFormat#NATIVE} and Hazelcast is OS. * * @param inMemoryFormat supplied inMemoryFormat */ private static void checkNotNativeWhenOpenSource(InMemoryFormat inMemoryFormat) { if (inMemoryFormat == NATIVE && !getBuildInfo().isEnterprise()) { throw new IllegalArgumentException("NATIVE storage format is supported in Hazelcast Enterprise only." + " Make sure you have Hazelcast Enterprise JARs on your classpath!"); } }
/** * Parses {@code hazelcast-runtime.properties} for {@code BuildInfo}; also checks for overrides in System.properties. * Never cache result of this method in a static context - as it can change due versions overriding - this method * already does caching whenever it's possible - i.e. when overrides is disabled. * * @return the parsed BuildInfo */ public static BuildInfo getBuildInfo() { if (Overrides.isEnabled()) { // never use cache when override is enabled -> we need to re-parse everything Overrides overrides = Overrides.fromProperties(); return getBuildInfoInternalVersion(overrides); } return BUILD_INFO_CACHE; }
private static String getVersion() { try { BuildInfo buildInfo = BuildInfoProvider.getBuildInfo(); return buildInfo.getVersion(); } catch (NoClassDefFoundError e) { // it's Hazelcast 3.2 or older return null; } }
@Override protected String getReleaseVersion() { BuildInfo buildInfo = BuildInfoProvider.getBuildInfo(); JetBuildInfo jetBuildInfo = buildInfo.getJetBuildInfo(); return jetBuildInfo.getVersion().substring(0, 3); }
protected String getReleaseVersion() { BuildInfo buildInfo = BuildInfoProvider.getBuildInfo(); String[] versionTokens = StringUtil.tokenizeVersionString(buildInfo.getVersion()); return versionTokens[0] + "." + versionTokens[1]; }
private boolean mustReadMapIndexInfos(Version version) { // 3.10 OS always reads mapIndexInfos // 3.10 EE always read mapIndexInfos when cluster version >= 3.10 // When cluster version is 3.9: // - an object input from 3.9 EE does not contain mapIndexInfo and arrives with UNKNOWN version // - an object input from 3.10 EE comes with version 3.9 and contains mapIndexInfo return !getBuildInfo().isEnterprise() || version.isGreaterOrEqual(V3_10); }
protected String getReleaseVersion() { BuildInfo buildInfo = BuildInfoProvider.getBuildInfo(); String[] versionTokens = StringUtil.tokenizeVersionString(buildInfo.getVersion()); return versionTokens[0] + "." + versionTokens[1]; }
static SnowcastConstants.HazelcastVersion getHazelcastVersion() { BuildInfo buildInfo = BuildInfoProvider.getBuildInfo(); if (buildInfo.getVersion() == null) { return SnowcastConstants.HazelcastVersion.Unknown; } if (buildInfo.getVersion().startsWith("3.7")) { return SnowcastConstants.HazelcastVersion.V_3_7; } else if (buildInfo.getVersion().startsWith("3.8")) { return SnowcastConstants.HazelcastVersion.V_3_8; } return SnowcastConstants.HazelcastVersion.Unknown; } }
void fillMetrics(final StringBuilder stats, final ClientConnection ownerConnection) { stats.append("lastStatisticsCollectionTime").append(KEY_VALUE_SEPARATOR).append(System.currentTimeMillis()); addStat(stats, "enterprise", enterprise); addStat(stats, "clientType", ClientType.JAVA.toString()); addStat(stats, "clientVersion", BuildInfoProvider.getBuildInfo().getVersion()); addStat(stats, "clusterConnectionTimestamp", ownerConnection.getStartTime()); stats.append(STAT_SEPARATOR).append("clientAddress").append(KEY_VALUE_SEPARATOR) .append(ownerConnection.getLocalSocketAddress().getAddress().getHostAddress()).append(":") .append(ownerConnection.getLocalSocketAddress().getPort()); addStat(stats, "clientName", client.getName()); ClientConnectionManagerImpl connectionManager = (ClientConnectionManagerImpl) client.getConnectionManager(); Credentials credentials = connectionManager.getLastCredentials(); if (credentials != null) { addStat(stats, "credentials.principal", credentials.getPrincipal()); } for (Gauge gauge : allGauges) { stats.append(STAT_SEPARATOR).append(gauge.getName()).append(KEY_VALUE_SEPARATOR); gauge.render(stats); } } }
private boolean mustReadMemberListJoinVersion(VersionAware versionAware) { return (!getBuildInfo().isEnterprise() || versionAware.getVersion().isGreaterOrEqual(V3_10)); } }