no IOException in Admin API

This commit is contained in:
Jörg Prante 2021-04-21 17:20:57 +02:00
parent afdbe1c7d2
commit 7e661271c1
2 changed files with 6 additions and 12 deletions

View file

@ -1,6 +1,5 @@
package org.xbib.elx.api; package org.xbib.elx.api;
import java.io.IOException;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
@ -9,7 +8,7 @@ import java.util.Map;
*/ */
public interface AdminClient extends BasicClient { public interface AdminClient extends BasicClient {
Map<String, ?> getMapping(IndexDefinition indexDefinition) throws IOException; Map<String, ?> getMapping(IndexDefinition indexDefinition);
void checkMapping(IndexDefinition indexDefinition); void checkMapping(IndexDefinition indexDefinition);
@ -25,9 +24,8 @@ public interface AdminClient extends BasicClient {
* @param indexDefinition the index definition * @param indexDefinition the index definition
* @param level the replica level * @param level the replica level
* @return this * @return this
* @throws IOException if replica setting could not be updated
*/ */
AdminClient updateReplicaLevel(IndexDefinition indexDefinition, int level) throws IOException; AdminClient updateReplicaLevel(IndexDefinition indexDefinition, int level);
/** /**
* Get replica level. * Get replica level.
@ -92,7 +90,6 @@ public interface AdminClient extends BasicClient {
* @param indexDefinition the index definition * @param indexDefinition the index definition
* @param timestampfieldname the timestamp field name * @param timestampfieldname the timestamp field name
* @return millis UTC millis of the most recent document * @return millis UTC millis of the most recent document
* @throws IOException if most rcent document can not be found
*/ */
Long mostRecentDocument(IndexDefinition indexDefinition, String timestampfieldname) throws IOException; Long mostRecentDocument(IndexDefinition indexDefinition, String timestampfieldname);
} }

View file

@ -53,7 +53,6 @@ import org.xbib.elx.api.IndexDefinition;
import org.xbib.elx.api.IndexPruneResult; import org.xbib.elx.api.IndexPruneResult;
import org.xbib.elx.api.IndexShiftResult; import org.xbib.elx.api.IndexShiftResult;
import java.io.IOException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collection; import java.util.Collection;
import java.util.Collections; import java.util.Collections;
@ -111,7 +110,7 @@ public abstract class AbstractAdminClient extends AbstractBasicClient implements
} }
@Override @Override
public AdminClient updateReplicaLevel(IndexDefinition indexDefinition, int level) throws IOException { public AdminClient updateReplicaLevel(IndexDefinition indexDefinition, int level) {
if (isIndexDefinitionDisabled(indexDefinition)) { if (isIndexDefinitionDisabled(indexDefinition)) {
return this; return this;
} }
@ -417,16 +416,14 @@ public abstract class AbstractAdminClient extends AbstractBasicClient implements
} }
@Override @Override
public void updateIndexSetting(String index, String key, Object value, long timeout, TimeUnit timeUnit) throws IOException { public void updateIndexSetting(String index, String key, Object value, long timeout, TimeUnit timeUnit) {
if (index == null) {
throw new IOException("no index name given");
}
ensureClientIsPresent(); ensureClientIsPresent();
Settings.Builder updateSettingsBuilder = Settings.builder(); Settings.Builder updateSettingsBuilder = Settings.builder();
updateSettingsBuilder.put(key, value.toString()); updateSettingsBuilder.put(key, value.toString());
UpdateSettingsRequest updateSettingsRequest = new UpdateSettingsRequest(index) UpdateSettingsRequest updateSettingsRequest = new UpdateSettingsRequest(index)
.settings(updateSettingsBuilder).timeout(toTimeValue(timeout, timeUnit)); .settings(updateSettingsBuilder).timeout(toTimeValue(timeout, timeUnit));
client.execute(UpdateSettingsAction.INSTANCE, updateSettingsRequest).actionGet(); client.execute(UpdateSettingsAction.INSTANCE, updateSettingsRequest).actionGet();
waitForCluster("GREEN", 300L, TimeUnit.SECONDS);
} }
@Override @Override