-
Notifications
You must be signed in to change notification settings - Fork 550
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added number_of_shards and number_of_replicas to information_schema.t…
…able_partitions and exposed these information in Map<PartitionName, PartitionInfo> returned by TableInfo.partitions()
- Loading branch information
Showing
25 changed files
with
772 additions
and
252 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
70 changes: 70 additions & 0 deletions
70
core/src/test/java/io/crate/core/NumberOfReplicasTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
/* | ||
* Licensed to CRATE Technology GmbH ("Crate") under one or more contributor | ||
* license agreements. See the NOTICE file distributed with this work for | ||
* additional information regarding copyright ownership. Crate 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. | ||
* | ||
* However, if you have executed another commercial license agreement | ||
* with Crate these terms will supersede the license and you may use the | ||
* software solely pursuant to the terms of the relevant commercial agreement. | ||
*/ | ||
|
||
package io.crate.core; | ||
|
||
import com.carrotsearch.randomizedtesting.RandomizedTest; | ||
import org.apache.lucene.util.BytesRef; | ||
import org.elasticsearch.common.settings.ImmutableSettings; | ||
import org.junit.Rule; | ||
import org.junit.Test; | ||
import org.junit.rules.ExpectedException; | ||
|
||
import static org.hamcrest.Matchers.is; | ||
|
||
public class NumberOfReplicasTest extends RandomizedTest { | ||
|
||
@Rule | ||
public ExpectedException expectedException = ExpectedException.none(); | ||
|
||
@Test | ||
public void testFromEmptySettings() throws Exception { | ||
BytesRef numberOfResplicas = NumberOfReplicas.fromSettings(ImmutableSettings.EMPTY); | ||
assertThat(numberOfResplicas.utf8ToString(), is("1")); | ||
} | ||
|
||
@Test | ||
public void testNumber() throws Exception { | ||
BytesRef numberOfResplicas = NumberOfReplicas.fromSettings(ImmutableSettings.builder() | ||
.put(NumberOfReplicas.NUMBER_OF_REPLICAS, 4) | ||
.build()); | ||
assertThat(numberOfResplicas.utf8ToString(), is("4")); | ||
} | ||
|
||
@Test | ||
public void testAutoExpandSettingsTakePrecedence() throws Exception { | ||
BytesRef numberOfResplicas = NumberOfReplicas.fromSettings(ImmutableSettings.builder() | ||
.put(NumberOfReplicas.AUTO_EXPAND_REPLICAS, "0-all") | ||
.put(NumberOfReplicas.NUMBER_OF_REPLICAS, 1) | ||
.build()); | ||
assertThat(numberOfResplicas.utf8ToString(), is("0-all")); | ||
} | ||
|
||
@Test | ||
public void testInvalidAutoExpandSettings() throws Exception { | ||
expectedException.expect(IllegalArgumentException.class); | ||
expectedException.expectMessage("The \"number_of_replicas\" range \"abc\" isn't valid"); | ||
NumberOfReplicas.fromSettings(ImmutableSettings.builder() | ||
.put(NumberOfReplicas.AUTO_EXPAND_REPLICAS, "abc") | ||
.put(NumberOfReplicas.NUMBER_OF_REPLICAS, 1) | ||
.build()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
/* | ||
* Licensed to CRATE Technology GmbH ("Crate") under one or more contributor | ||
* license agreements. See the NOTICE file distributed with this work for | ||
* additional information regarding copyright ownership. Crate 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. | ||
* | ||
* However, if you have executed another commercial license agreement | ||
* with Crate these terms will supersede the license and you may use the | ||
* software solely pursuant to the terms of the relevant commercial agreement. | ||
*/ | ||
|
||
package io.crate.metadata; | ||
|
||
import com.google.common.base.MoreObjects; | ||
import org.apache.lucene.util.BytesRef; | ||
|
||
import java.util.Map; | ||
|
||
public class PartitionInfo { | ||
private final PartitionName name; | ||
private final int numberOfShards; | ||
private final BytesRef numberOfReplicas; | ||
private final Map<String, Object> values; | ||
|
||
public PartitionInfo(PartitionName name, | ||
int numberOfShards, | ||
BytesRef numberOfReplicas, | ||
Map<String, Object> values) { | ||
this.name = name; | ||
this.numberOfShards = numberOfShards; | ||
this.numberOfReplicas = numberOfReplicas; | ||
this.values = values; | ||
} | ||
|
||
public PartitionName name() { | ||
return name; | ||
} | ||
|
||
public int numberOfShards() { | ||
return numberOfShards; | ||
} | ||
|
||
public BytesRef numberOfReplicas() { | ||
return numberOfReplicas; | ||
} | ||
|
||
public Map<String, Object> values() { | ||
return values; | ||
} | ||
|
||
@Override | ||
public boolean equals(Object o) { | ||
if (this == o) return true; | ||
if (o == null || getClass() != o.getClass()) return false; | ||
|
||
PartitionInfo that = (PartitionInfo) o; | ||
|
||
if (!name.equals(that.name)) return false; | ||
if (numberOfReplicas != that.numberOfReplicas) return false; | ||
if (numberOfShards != that.numberOfShards) return false; | ||
|
||
return true; | ||
} | ||
|
||
@Override | ||
public int hashCode() { | ||
int result = name.hashCode(); | ||
result = 31 * result + numberOfShards; | ||
result = 31 * result + numberOfReplicas.hashCode(); | ||
return result; | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return MoreObjects.toStringHelper(this) | ||
.add("name", name) | ||
.add("numberOfShards", numberOfShards) | ||
.add("numberOfReplicas", numberOfReplicas) | ||
.toString(); | ||
} | ||
} |
Oops, something went wrong.