Skip to content

Commit

Permalink
Improve UpdateChecker
Browse files Browse the repository at this point in the history
### What changes are proposed in this pull request?

Improve UpdateChecker

### Why are the changes needed?

  1. remove irrelevant master features 
  2. turn on fuse update check


			pr-link: Alluxio#18101
			change-id: cid-8f6801fedda5f7710d111939e50cfd5f4372b7e5
  • Loading branch information
apc999 authored Nov 7, 2023
1 parent bd99175 commit 246c7ee
Show file tree
Hide file tree
Showing 20 changed files with 425 additions and 758 deletions.
9 changes: 9 additions & 0 deletions dora/core/common/src/main/java/alluxio/conf/PropertyKey.java
Original file line number Diff line number Diff line change
Expand Up @@ -6423,6 +6423,13 @@ public String toString() {
.setConsistencyCheckLevel(ConsistencyCheckLevel.IGNORE)
.setScope(Scope.CLIENT)
.build();
public static final PropertyKey FUSE_UPDATE_CHECK_ENABLED =
booleanBuilder(Name.FUSE_UPDATE_CHECK_ENABLED)
.setDefaultValue(Boolean.parseBoolean(ProjectConstants.UPDATE_CHECK_ENABLED))
.setDescription("Whether to check for update availability for alluxio-fuse")
.setConsistencyCheckLevel(ConsistencyCheckLevel.ENFORCE)
.setIsHidden(true)
.build();
public static final PropertyKey FUSE_USER_GROUP_TRANSLATION_ENABLED =
booleanBuilder(Name.FUSE_USER_GROUP_TRANSLATION_ENABLED)
.setDefaultValue(false)
Expand Down Expand Up @@ -8490,6 +8497,8 @@ public static final class Name {
"alluxio.fuse.stat.cache.refresh.interval";
public static final String FUSE_UMOUNT_TIMEOUT =
"alluxio.fuse.umount.timeout";
public static final String FUSE_UPDATE_CHECK_ENABLED =
"alluxio.fuse.update.check.enabled";
public static final String FUSE_USER_GROUP_TRANSLATION_ENABLED =
"alluxio.fuse.user.group.translation.enabled";
public static final String FUSE_SPECIAL_COMMAND_ENABLED =
Expand Down
5 changes: 3 additions & 2 deletions dora/core/common/src/main/java/alluxio/util/CommonUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -678,14 +678,15 @@ public static RuntimeException closeAndRethrowRuntimeException(Closer closer, Th

/** Alluxio process types. */
public enum ProcessType {
CLIENT,
FUSE,
JOB_MASTER,
JOB_WORKER,
CLIENT,
MASTER,
PLUGIN,
PROXY,
SECURITY,
WORKER;
WORKER,
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,10 @@
* See the NOTICE file distributed with this work for information regarding copyright ownership.
*/

package alluxio.check;
package alluxio.util;

import alluxio.ProjectConstants;
import alluxio.exception.runtime.FailedPreconditionRuntimeException;
import alluxio.util.EnvironmentUtils;
import alluxio.util.FeatureUtils;
import alluxio.util.OSUtils;

import com.amazonaws.util.EC2MetadataUtils;
import com.google.common.annotations.VisibleForTesting;
Expand All @@ -39,7 +36,7 @@
* Check for updates.
*/
@ThreadSafe
public final class UpdateCheck {
public final class UpdateCheckUtils {
public static final String USER_AGENT_SEPARATOR = ";";

static final String PRODUCT_CODE_FORMAT = "ProductCode:%s";
Expand All @@ -49,51 +46,36 @@ public final class UpdateCheck {
static final String CFT_KEY = "cft";
static final String DOCKER_KEY = "docker";
static final String EC2_KEY = "ec2";
static final String EMBEDDED_KEY = "embedded";
static final String EMR_KEY = "emr";
static final String GCE_KEY = "gce";
static final String KUBERNETES_KEY = "kubernetes";

// Feature
static final String BACKUP_DELEGATION_KEY = "backupDelegation";
static final String DAILY_BACKUP_KEY = "dailyBackup";
static final String MASTER_AUDIT_LOG_KEY = "masterAuditLog";
static final String PERSIST_BLACK_LIST_KEY = "persistBlackList";
static final String PAGE_STORE_KEY = "pageStore";
static final String INODE_METASTORE_ROCKS_KEY = "inodeRocks";
static final String BLOCK_METASTORE_ROCKS_KEY = "blockRocks";
static final String UNSAFE_PERSIST_KEY = "unsafePersist";
static final String ZOOKEEPER_KEY = "zookeeper";

/**
* @param id the id of the current Alluxio identity (e.g. cluster id, instance id)
* @param processType process type
* @param additionalInfo additional information to send
* @param connectionRequestTimeout the connection request timeout for the HTTP request in ms
* @param connectTimeout the connection timeout for the HTTP request in ms
* @param socketTimeout the socket timeout for the HTTP request in ms
* @return the latest Alluxio version string
*/
public static String getLatestVersion(String id, List<String> additionalInfo,
long connectionRequestTimeout, long connectTimeout, long socketTimeout)
throws IOException {
public static String getLatestVersion(String id, CommonUtils.ProcessType processType,
List<String> additionalInfo) throws IOException {
Preconditions.checkState(id != null && !id.isEmpty(), "id should not be null or empty");
Preconditions.checkNotNull(additionalInfo);
// Create the GET request.
Joiner joiner = Joiner.on("/");
String path = joiner.join("v0", "version");
String path = joiner.join("v1", "version");
String url = new URL(new URL(ProjectConstants.UPDATE_CHECK_HOST), path).toString();

HttpGet post = new HttpGet(url);
post.setHeader("User-Agent", getUserAgentString(id, additionalInfo));
post.setHeader("User-Agent", getUserAgentString(id, processType, additionalInfo));
post.setHeader("Authorization", "Basic " + ProjectConstants.UPDATE_CHECK_MAGIC_NUMBER);

// Fire off the version check request.
HttpClient client = HttpClientBuilder.create()
.setDefaultRequestConfig(
RequestConfig.custom()
.setConnectionRequestTimeout((int) connectionRequestTimeout)
.setConnectTimeout((int) connectTimeout)
.setSocketTimeout((int) socketTimeout)
.setConnectionRequestTimeout(3000)
.setConnectTimeout(3000)
.setSocketTimeout(3000)
.build())
.build();
HttpResponse response = client.execute(post);
Expand All @@ -110,17 +92,19 @@ public static String getLatestVersion(String id, List<String> additionalInfo,

/**
* @param id the id of the current Alluxio identity (e.g. cluster id, instance id)
* @param processType process type
* @param additionalInfo additional information to add to result string
* @return a string representation of the user's environment in the format
* "Alluxio/{ALLUXIO_VERSION} (valueA; valueB)"
*/
@VisibleForTesting
public static String getUserAgentString(String id, List<String> additionalInfo) {
public static String getUserAgentString(String id, CommonUtils.ProcessType processType,
List<String> additionalInfo) {
List<String> info = new ArrayList<>();
info.add(id);
addUserAgentEnvironments(info);
addUserAgentFeatures(info);
info.addAll(additionalInfo);
info.add(String.format("processType:%s", processType.toString()));
return String.format("Alluxio/%s (%s)", ProjectConstants.VERSION,
Joiner.on(USER_AGENT_SEPARATOR + " ").skipNulls().join(info));
}
Expand All @@ -146,38 +130,6 @@ public static void addUserAgentEnvironments(List<String> info) {
}
}

/**
* Get the feature's information.
*
* @param info the list to add info to
*/
@VisibleForTesting
public static void addUserAgentFeatures(List<String> info) {
addIfTrue(FeatureUtils.isEmbeddedJournal(), info, EMBEDDED_KEY);
addIfTrue(FeatureUtils.isInodeStoreRocks(), info, INODE_METASTORE_ROCKS_KEY);
addIfTrue(FeatureUtils.isBlockStoreRocks(), info, BLOCK_METASTORE_ROCKS_KEY);
addIfTrue(FeatureUtils.isZookeeperEnabled(), info, ZOOKEEPER_KEY);
addIfTrue(FeatureUtils.isBackupDelegationEnabled(), info, BACKUP_DELEGATION_KEY);
addIfTrue(FeatureUtils.isDailyBackupEnabled(), info, DAILY_BACKUP_KEY);
addIfTrue(!FeatureUtils.isPersistenceBlacklistEmpty(), info, PERSIST_BLACK_LIST_KEY);
addIfTrue(FeatureUtils.isUnsafeDirectPersistEnabled(), info, UNSAFE_PERSIST_KEY);
addIfTrue(FeatureUtils.isMasterAuditLoggingEnabled(), info, MASTER_AUDIT_LOG_KEY);
addIfTrue(FeatureUtils.isPageStoreEnabled(), info, PAGE_STORE_KEY);
}

/**
* Add feature name if condition is true.
*
* @param valid true, if condition is valid
* @param features feature list
* @param featureName feature name
*/
public static void addIfTrue(boolean valid, List<String> features, String featureName) {
if (valid) {
features.add(featureName);
}
}

/**
* Adds the information of EC2 environment to given list.
*
Expand Down Expand Up @@ -214,5 +166,5 @@ private static void addEC2Info(List<String> info) {
}
}

private UpdateCheck() {} // prevent instantiation
private UpdateCheckUtils() {} // prevent instantiation
}
Loading

0 comments on commit 246c7ee

Please sign in to comment.