carbondata-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gvramana <...@git.apache.org>
Subject [GitHub] carbondata pull request #1147: [CARBONDATA-1277] Dictionary generation failu...
Date Mon, 10 Jul 2017 13:27:24 GMT
Github user gvramana commented on a diff in the pull request:

    https://github.com/apache/carbondata/pull/1147#discussion_r126420489
  
    --- Diff: core/src/main/java/org/apache/carbondata/core/util/path/HDFSUtils.java ---
    @@ -0,0 +1,188 @@
    +/*
    + * Licensed to the Apache Software Foundation (ASF) under one or more
    + * contributor license agreements.  See the NOTICE file distributed with
    + * this work for additional information regarding copyright ownership.
    + * The ASF licenses this file to You under the Apache License, Version 2.0
    + * (the "License"); you may not use this file except in compliance with
    + * the License.  You may obtain a copy of the License at
    + *
    + *    http://www.apache.org/licenses/LICENSE-2.0
    + *
    + * Unless required by applicable law or agreed to in writing, software
    + * distributed under the License is distributed on an "AS IS" BASIS,
    + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    + * See the License for the specific language governing permissions and
    + * limitations under the License.
    + */
    +
    +package org.apache.carbondata.core.util.path;
    +
    +import java.io.FileNotFoundException;
    +import java.io.IOException;
    +
    +import org.apache.carbondata.common.logging.LogService;
    +import org.apache.carbondata.common.logging.LogServiceFactory;
    +import org.apache.carbondata.core.constants.CarbonCommonConstants;
    +import org.apache.carbondata.core.datastore.impl.FileFactory;
    +import org.apache.carbondata.core.util.CarbonProperties;
    +
    +import org.apache.hadoop.fs.FileSystem;
    +import org.apache.hadoop.fs.Path;
    +import org.apache.hadoop.hdfs.DistributedFileSystem;
    +import org.apache.hadoop.hdfs.server.namenode.LeaseExpiredException;
    +
    +/**
    + * Implementation for HDFS utility methods
    + */
    +public class HDFSUtils {
    +
    +  private static final int CARBON_LEASE_RECOVERY_RETRY_COUNT_MIN = 1;
    +  private static final int CARBON_LEASE_RECOVERY_RETRY_COUNT_MAX = 5;
    +  private static final String CARBON_LEASE_RECOVERY_RETRY_COUNT_DEFAULT = "3";
    +  private static final int CARBON_LEASE_RECOVERY_RETRY_INTERVAL_MIN = 100;
    +  private static final int CARBON_LEASE_RECOVERY_RETRY_INTERVAL_MAX = 10000;
    +  private static final String CARBON_LEASE_RECOVERY_RETRY_INTERVAL_DEFAULT = "1000";
    +
    +  /**
    +   * LOGGER
    +   */
    +  private static final LogService LOGGER =
    +      LogServiceFactory.getLogService(HDFSUtils.class.getName());
    +
    +  /**
    +   * This method will validate whether the exception thrown if for lease recovery from
HDFS
    +   *
    +   * @param message
    +   * @return
    +   */
    +  public static boolean checkExceptionMessageForLeaseRecovery(String message) {
    +    // depending on the scenario few more cases can be added for validating lease recovery
exception
    +    if (null != message && message.contains("Failed to APPEND_FILE")) {
    +      return true;
    +    }
    +    return false;
    +  }
    +
    +  /**
    +   * This method will make attempts to recover lease on a file using the
    +   * distributed file system utility.
    +   *
    +   * @param filePath
    +   * @return
    +   * @throws IOException
    +   */
    +  public static boolean recoverFileLease(String filePath) throws IOException {
    +    LOGGER.info("Trying to recover lease on file: " + filePath);
    +    FileFactory.FileType fileType = FileFactory.getFileType(filePath);
    +    switch (fileType) {
    +      case ALLUXIO:
    +      case HDFS:
    +      case VIEWFS:
    +        DistributedFileSystem dfs = null;
    +        Path path = FileFactory.getPath(filePath);
    +        FileSystem fs = FileFactory.getFileSystem(path);
    +        dfs = (DistributedFileSystem) fs;
    +        int maxAttempts = getLeaseRecoveryRetryCount();
    +        int retryInterval = getLeaseRecoveryRetryInterval();
    +        boolean leaseRecovered = false;
    +        IOException ioException = null;
    +        for (int retryCount = 1; retryCount <= maxAttempts; retryCount++) {
    +          try {
    +            leaseRecovered = dfs.recoverLease(path);
    --- End diff --
    
    check viwefs lease recovery mechanism


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

Mime
View raw message