本文整理了Java中org.batfish.common.Version
类的一些代码示例,展示了Version
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Version
类的具体详情如下:
包路径:org.batfish.common.Version
类名称:Version
[英]A utility class to determine the version of Batfish being used and check compatibility between different endpoints across API calls.
[中]一个实用程序类,用于确定使用的蝙蝠鱼版本,并跨API调用检查不同端点之间的兼容性。
代码示例来源:origin: batfish/batfish
@GET
@Produces(MediaType.APPLICATION_JSON)
public JSONArray getInfo() {
_logger.info("PMS:getInfo\n");
return new JSONArray(
Arrays.asList(
CoordConsts.SVC_KEY_SUCCESS,
"Batfish coordinator v"
+ Version.getVersion()
+ ". Enter ../application.wadl (relative to your URL) to see supported methods"));
}
代码示例来源:origin: batfish/batfish
/**
* Returns {@code true} if the given version of some other endpoint is compatible with the Batfish
* version of this process.
*
* <p>At the time of writing, compatibility is determined on having identical major and minor
* versions.
*/
public static boolean isCompatibleVersion(
String myName, String otherName, @Nullable String otherVersion) {
return isCompatibleVersion(myName, getVersion(), otherName, otherVersion);
}
代码示例来源:origin: batfish/batfish
/**
* Checks whether the supplied version for another endpoint is compatible with the Batfish version
* of this process, and throws an error if not.
*
* @see #checkCompatibleVersion(String, String, String)
*/
public static void checkCompatibleVersion(
String myName, String otherName, @Nullable String otherVersion) {
checkCompatibleVersion(myName, getVersion(), otherName, otherVersion);
}
代码示例来源:origin: batfish/batfish
/** Returns string indicating the current build of Batfish and Z3. */
public static String getCompleteVersionString() {
return String.format("Batfish version: %s\nZ3 version: %s\n", getVersion(), getZ3Version());
}
代码示例来源:origin: batfish/batfish
static void checkCompatibleVersion(
String myName, String myVersion, String otherName, @Nullable String otherVersion) {
checkArgument(
isCompatibleVersion(myName, myVersion, otherName, otherVersion),
"%s version: '%s' is not compatible with %s version: '%s'",
otherName,
otherVersion,
myName,
myVersion);
}
代码示例来源:origin: batfish/batfish
private void checkClientVersion(String clientVersion) {
Version.checkCompatibleVersion("Service", "Client", clientVersion);
}
代码示例来源:origin: batfish/batfish
System.out.print(Version.getCompleteVersionString());
System.exit(0);
代码示例来源:origin: batfish/batfish
static boolean isCompatibleVersion(
String myName, String myVersion, String otherName, @Nullable String otherVersion) {
String effectiveOtherVersion = firstNonNull(otherVersion, UNKNOWN_VERSION);
if (effectiveOtherVersion.equals(INCOMPATIBLE_VERSION)
|| myVersion.equals(INCOMPATIBLE_VERSION)) {
return false;
}
if (effectiveOtherVersion.equals(UNKNOWN_VERSION) || myVersion.equals(UNKNOWN_VERSION)) {
// Either version is unknown, assume compatible.
return true;
}
DefaultArtifactVersion myArtifactVersion = parseVersion(myVersion, myName);
DefaultArtifactVersion otherArtifactVersion = parseVersion(effectiveOtherVersion, otherName);
return myArtifactVersion.getMajorVersion() == otherArtifactVersion.getMajorVersion()
&& myArtifactVersion.getMinorVersion() == otherArtifactVersion.getMinorVersion();
}
代码示例来源:origin: batfish/batfish
private boolean cachedConfigsAreCompatible(NetworkId network, SnapshotId snapshot) {
try {
ConvertConfigurationAnswerElement ccae =
loadConvertConfigurationAnswerElement(network, snapshot);
return ccae != null
&& Version.isCompatibleVersion(
FileBasedStorage.class.getCanonicalName(),
"Old processed configurations",
ccae.getVersion());
} catch (BatfishException e) {
_logger.warnf(
"Unexpected exception caught while deserializing configs for snapshot %s: %s",
snapshot, Throwables.getStackTraceAsString(e));
return false;
}
}
代码示例来源:origin: batfish/batfish
@Test
public void checkCompatibleVersion() {
Version.checkCompatibleVersion("foo", "1.2.3", "other", "1.2.3");
Version.checkCompatibleVersion("foo", "1.2.3", "other", "1.2.4");
Version.checkCompatibleVersion("foo", UNKNOWN_VERSION, "other", "1.2.4");
Version.checkCompatibleVersion("foo", "1.2.3", "other", UNKNOWN_VERSION);
Version.checkCompatibleVersion("foo", "1.2.3", "other", "1.2.3-SNAPSHOT");
}
代码示例来源:origin: batfish/batfish
System.out.print(Version.getCompleteVersionString());
return;
代码示例来源:origin: batfish/batfish
private static boolean registerWithCoordinator(String poolRegUrl, int listenPort) {
Map<String, String> params = new HashMap<>();
params.put(CoordConsts.SVC_KEY_ADD_WORKER, _mainSettings.getServiceHost() + ":" + listenPort);
params.put(CoordConsts.SVC_KEY_VERSION, Version.getVersion());
Object response = talkToCoordinator(poolRegUrl, params, _mainLogger);
return response != null;
}
代码示例来源:origin: batfish/batfish
@Override
public void filter(ContainerRequestContext requestContext) {
String clientVersion = requestContext.getHeaderString(HTTP_HEADER_BATFISH_VERSION);
if (Strings.isNullOrEmpty(clientVersion)) {
requestContext.abortWith(
Response.status(Status.BAD_REQUEST)
.entity(
String.format(
"HTTP header %s should contain a client version",
HTTP_HEADER_BATFISH_VERSION))
.type(MediaType.APPLICATION_JSON)
.build());
} else if (!Version.isCompatibleVersion("Service", "Client", clientVersion)) {
requestContext.abortWith(
Response.status(Status.BAD_REQUEST)
.entity(
String.format(
"Client version '%s' is not compatible with server version '%s'",
clientVersion, Version.getVersion()))
.type(MediaType.APPLICATION_JSON)
.build());
}
}
}
代码示例来源:origin: batfish/batfish
@Test
public void isCompatibleVersion() {
// identical versions
assertTrue(Version.isCompatibleVersion("foo", "1.2.3", "other", "1.2.3"));
// compatible versions, different patch version
assertTrue(Version.isCompatibleVersion("foo", "1.2.3", "other", "1.2.4"));
// mine unknown
assertTrue(Version.isCompatibleVersion("foo", UNKNOWN_VERSION, "other", "1.2.4"));
// other unknown
assertTrue(Version.isCompatibleVersion("foo", "1.2.3", "other", UNKNOWN_VERSION));
// SNAPSHOT
assertTrue(Version.isCompatibleVersion("foo", "1.2.3", "other", "1.2.3-SNAPSHOT"));
// Other newer minor
assertFalse(Version.isCompatibleVersion("foo", "1.2.3", "other", "1.3.3"));
// Other newer major
assertFalse(Version.isCompatibleVersion("foo", "1.2.3", "other", "2.2.3"));
// Other older minor
assertFalse(Version.isCompatibleVersion("foo", "1.2.3", "other", "1.1.3"));
// Other older major
assertFalse(Version.isCompatibleVersion("foo", "1.2.3", "other", "0.2.3"));
}
代码示例来源:origin: batfish/batfish
@Test
public void checkIncompatibleVersion() {
_thrown.expect(IllegalArgumentException.class);
_thrown.expectMessage("other version: '1.3.3' is not compatible with foo version: '1.2.3'");
Version.checkCompatibleVersion("foo", "1.2.3", "other", "1.3.3");
}
代码示例来源:origin: batfish/batfish
@VisibleForTesting
@JsonCreator
ConvertConfigurationAnswerElement(
@JsonProperty(PROP_DEFINED_STRUCTURES)
SortedMap<String, SortedMap<String, SortedMap<String, DefinedStructureInfo>>>
definedStructures,
@JsonProperty(PROP_REFERENCED_STRUCTURES)
SortedMap<
String,
SortedMap<String, SortedMap<String, SortedMap<String, SortedSet<Integer>>>>>
referencedstructures,
@JsonProperty(PROP_CONVERT_STATUS) SortedMap<String, ConvertStatus> convertStatus,
@JsonProperty(PROP_ERRORS) SortedMap<String, BatfishException.BatfishStackTrace> errors,
@JsonProperty(PROP_UNDEFINED_REFERENCES)
SortedMap<
String,
SortedMap<String, SortedMap<String, SortedMap<String, SortedSet<Integer>>>>>
undefinedReferences,
@JsonProperty(PROP_VERSION) String version,
@JsonProperty(PROP_WARNINGS) SortedMap<String, Warnings> warnings) {
_definedStructures = firstNonNull(definedStructures, new TreeMap<>());
_errors = firstNonNull(errors, new TreeMap<>());
_convertStatus = firstNonNull(convertStatus, new TreeMap<>());
_referencedStructures = firstNonNull(referencedstructures, new TreeMap<>());
_undefinedReferences = firstNonNull(undefinedReferences, new TreeMap<>());
_version = firstNonNull(version, Version.getVersion());
_warnings = firstNonNull(warnings, new TreeMap<>());
}
代码示例来源:origin: batfish/batfish
Arrays.asList(CoordConsts.SVC_KEY_FAILURE, "Worker version not specified"));
if (!Version.isCompatibleVersion("Service", "Worker", workerVersion)) {
return new JSONArray(
Arrays.asList(
+ workerVersion
+ "is incompatible with coordinator version "
+ Version.getVersion()));
代码示例来源:origin: batfish/batfish
@Override
public SortedMap<String, BgpAdvertisementsByVrf> loadEnvironmentBgpTables() {
NetworkSnapshot snapshot = getNetworkSnapshot();
SortedMap<String, BgpAdvertisementsByVrf> environmentBgpTables =
_cachedEnvironmentBgpTables.get(snapshot);
if (environmentBgpTables == null) {
ParseEnvironmentBgpTablesAnswerElement ae = loadParseEnvironmentBgpTablesAnswerElement();
if (!Version.isCompatibleVersion(
"Service", "Old processed environment BGP tables", ae.getVersion())) {
repairEnvironmentBgpTables();
}
environmentBgpTables =
deserializeEnvironmentBgpTables(_testrigSettings.getSerializeEnvironmentBgpTablesPath());
_cachedEnvironmentBgpTables.put(snapshot, environmentBgpTables);
}
return environmentBgpTables;
}
代码示例来源:origin: batfish/batfish
@GET
@Path(CoordConsts.SVC_RSC_GETSTATUS)
@Produces(MediaType.APPLICATION_JSON)
public JSONArray getStatus() {
try {
_logger.info("WMS:getStatus\n");
JSONObject retObject = Main.getWorkMgr().getStatusJson();
retObject.put("service-version", Version.getVersion());
return successResponse(retObject);
} catch (Exception e) {
String stackTrace = Throwables.getStackTraceAsString(e);
_logger.errorf("WMS:getStatus exception: %s", stackTrace);
return failureResponse(e.getMessage());
}
}
代码示例来源:origin: batfish/batfish
@Override
public SortedMap<String, RoutesByVrf> loadEnvironmentRoutingTables() {
NetworkSnapshot snapshot = getNetworkSnapshot();
SortedMap<String, RoutesByVrf> environmentRoutingTables =
_cachedEnvironmentRoutingTables.get(snapshot);
if (environmentRoutingTables == null) {
ParseEnvironmentRoutingTablesAnswerElement pertae =
loadParseEnvironmentRoutingTablesAnswerElement();
if (!Version.isCompatibleVersion(
"Service", "Old processed environment routing tables", pertae.getVersion())) {
repairEnvironmentRoutingTables();
}
environmentRoutingTables =
deserializeEnvironmentRoutingTables(
_testrigSettings.getSerializeEnvironmentRoutingTablesPath());
_cachedEnvironmentRoutingTables.put(snapshot, environmentRoutingTables);
}
return environmentRoutingTables;
}
内容来源于网络,如有侵权,请联系作者删除!