From c48f927d10734d3e596293f8d33fe28b5541af7e Mon Sep 17 00:00:00 2001 From: Noble Paul Date: Wed, 1 Oct 2014 15:58:15 +0000 Subject: [PATCH] SOLR-6476 git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1628747 13f79535-47bb-0310-9956-ffa450edef68 --- .../src/java/org/apache/solr/schema/SchemaManager.java | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/solr/core/src/java/org/apache/solr/schema/SchemaManager.java b/solr/core/src/java/org/apache/solr/schema/SchemaManager.java index 096031f2e37..6ca05e624f5 100644 --- a/solr/core/src/java/org/apache/solr/schema/SchemaManager.java +++ b/solr/core/src/java/org/apache/solr/schema/SchemaManager.java @@ -39,6 +39,7 @@ import java.util.LinkedHashMap; import java.util.List; import java.util.Map; import java.util.Set; +import java.util.concurrent.TimeUnit; import static java.util.Collections.EMPTY_LIST; import static java.util.Collections.EMPTY_MAP; @@ -156,15 +157,13 @@ public class SchemaManager { String collection = cd.getCollectionName(); if (collection != null) { ZkSolrResourceLoader zkLoader = (ZkSolrResourceLoader) managedIndexSchema.getResourceLoader(); - long timeLeftSecs1 = timeout - ((System.nanoTime() - startTime) /1000000); - int secsLeft = (int) (timeLeftSecs1 > 0 ? timeLeftSecs1 : -1); - if(secsLeft<=0) throw new SolrException(SolrException.ErrorCode.SERVER_ERROR, "Not enough time left to update replicas. However the schema is updated already"); - long timeLeftSecs = timeout - ((System.nanoTime() - startTime) /1000000); + long timeLeftSecs = timeout - TimeUnit.SECONDS.convert(System.nanoTime() - startTime, TimeUnit.NANOSECONDS); + if(timeLeftSecs<=0) throw new SolrException(SolrException.ErrorCode.SERVER_ERROR, "Not enough time left to update replicas. However the schema is updated already"); ManagedIndexSchema.waitForSchemaZkVersionAgreement(collection, cd.getCloudDescriptor().getCoreNodeName(), (managedIndexSchema).getSchemaZkVersion(), zkLoader.getZkController(), - (int) (timeLeftSecs > 0 ? timeLeftSecs : -1)); + (int) timeLeftSecs); } }