vikramahuja1001 commented on a change in pull request #3917:
URL: https://github.com/apache/carbondata/pull/3917#discussion_r516789854
##########
File path:
core/src/main/java/org/apache/carbondata/core/util/CarbonProperties.java
##########
@@ -2116,6 +2087,28 @@ public int getMaxSIRepairLimit(String dbName, String
tableName) {
return Math.abs(Integer.parseInt(thresholdValue));
}
+ /**
+ * The below method returns the microseconds after which the trash folder
will expire
+ */
+ public long getTrashFolderExpirationTime() {
+ String configuredValue =
getProperty(CarbonCommonConstants.CARBON_TRASH_EXPIRATION_DAYS,
+ CarbonCommonConstants.CARBON_TRASH_EXPIRATION_DAYS_DEFAULT);
+ Integer result = 0;
+ try {
+ result = Integer.parseInt(configuredValue);
+ if (result < 0) {
+ LOGGER.warn("Value of carbon.trash.expiration.days is negative, taking
default value");
+ result = Integer.parseInt(CARBON_TRASH_EXPIRATION_DAYS_DEFAULT);
+ }
+ } catch (NumberFormatException e) {
+ LOGGER.error("Invalid value configured for CarbonCommonConstants" +
+ ".CARBON_TRASH_EXPIRATION_DAYS, considering the default value");
Review comment:
done
##########
File path:
core/src/main/java/org/apache/carbondata/core/util/CarbonProperties.java
##########
@@ -2116,6 +2087,28 @@ public int getMaxSIRepairLimit(String dbName, String
tableName) {
return Math.abs(Integer.parseInt(thresholdValue));
}
+ /**
+ * The below method returns the microseconds after which the trash folder
will expire
+ */
+ public long getTrashFolderExpirationTime() {
+ String configuredValue =
getProperty(CarbonCommonConstants.CARBON_TRASH_EXPIRATION_DAYS,
+ CarbonCommonConstants.CARBON_TRASH_EXPIRATION_DAYS_DEFAULT);
+ Integer result = 0;
+ try {
+ result = Integer.parseInt(configuredValue);
+ if (result < 0) {
+ LOGGER.warn("Value of carbon.trash.expiration.days is negative, taking
default value");
+ result = Integer.parseInt(CARBON_TRASH_EXPIRATION_DAYS_DEFAULT);
+ }
+ } catch (NumberFormatException e) {
+ LOGGER.error("Invalid value configured for CarbonCommonConstants" +
+ ".CARBON_TRASH_EXPIRATION_DAYS, considering the default value");
+ result = Integer.parseInt(CARBON_TRASH_EXPIRATION_DAYS_DEFAULT);
+ }
+ Long microSecondsInADay = Long.valueOf(TimeUnit.DAYS.toMillis(1));
+ return result * microSecondsInADay;
Review comment:
done
##########
File path: core/src/main/java/org/apache/carbondata/core/util/CarbonUtil.java
##########
@@ -3441,4 +3443,33 @@ public static void agingTempFolderForIndexServer(long
agingTime)throws
});
}
}
+
+ /**
+ * The below method tries to get the segment lock for the given segment.
+ */
+ public static boolean tryGettingSegmentLock(LoadMetadataDetails oneLoad,
+ AbsoluteTableIdentifier absoluteTableIdentifier) {
+ ICarbonLock segmentLock =
CarbonLockFactory.getCarbonLockObj(absoluteTableIdentifier,
+ CarbonTablePath.addSegmentPrefix(oneLoad.getLoadName()) +
LockUsage.LOCK);
+ boolean canBeDeleted;
+ try {
+ if (segmentLock.lockWithRetries(CarbonCommonConstants
+ .NUMBER_OF_TRIES_FOR_CARBON_LOCK_DEFAULT, CarbonCommonConstants
+ .MAX_TIMEOUT_FOR_CARBON_LOCK_DEFAULT)) {
+ LOGGER.info("Info: Acquired segment lock on segment: " +
oneLoad.getLoadName() + ". It " +
+ "can be deleted as load is not in progress");
+ canBeDeleted = true;
+ } else {
+ LOGGER.info("Info: Load in progress for segment" +
oneLoad.getLoadName());
+ canBeDeleted = false;
+ }
+ } finally {
+ if (segmentLock.unlock()) {
+ LOGGER.info("Info: Segment lock on segment:" + oneLoad.getLoadName() +
" is released");
+ } else {
+ LOGGER.error("Error: Unable to release segment lock on : " +
oneLoad.getLoadName());
Review comment:
done
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]