Skip to content

Commit

Permalink
add gateway recovery status to the indices status API exposing both o…
Browse files Browse the repository at this point in the history
…n going and summary when recovering from a gateway
  • Loading branch information
kimchy committed Aug 17, 2010
1 parent 311520d commit 3f9034b
Show file tree
Hide file tree
Showing 13 changed files with 577 additions and 258 deletions.
@@ -0,0 +1,179 @@
/*
* Licensed to Elastic Search and Shay Banon under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. Elastic Search 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.elasticsearch.action.admin.indices.status;

import org.elasticsearch.ElasticSearchIllegalArgumentException;
import org.elasticsearch.common.unit.ByteSizeValue;
import org.elasticsearch.common.unit.TimeValue;

/**
* @author kimchy (shay.banon)
*/
public class GatewayRecoveryStatus {

public enum Stage {
INIT((byte) 0),
RETRY((byte) 1),
INDEX((byte) 2),
TRANSLOG((byte) 3),
FINALIZE((byte) 4),
DONE((byte) 5);

private final byte value;

Stage(byte value) {
this.value = value;
}

public byte value() {
return value;
}

public static Stage fromValue(byte value) {
if (value == 0) {
return INIT;
} else if (value == 1) {
return RETRY;
} else if (value == 2) {
return INDEX;
} else if (value == 3) {
return TRANSLOG;
} else if (value == 4) {
return FINALIZE;
} else if (value == 5) {
return DONE;
}
throw new ElasticSearchIllegalArgumentException("No stage found for [" + value + ']');
}
}

final Stage stage;

final long startTime;

final long time;

final long throttlingTime;

final long indexThrottlingTime;

final long indexSize;

final long reusedIndexSize;

final long recoveredIndexSize;

final long recoveredTranslogOperations;

public GatewayRecoveryStatus(Stage stage, long startTime, long time, long throttlingTime, long indexThrottlingTime, long indexSize, long reusedIndexSize,
long recoveredIndexSize, long recoveredTranslogOperations) {
this.stage = stage;
this.startTime = startTime;
this.time = time;
this.throttlingTime = throttlingTime;
this.indexThrottlingTime = indexThrottlingTime;
this.indexSize = indexSize;
this.reusedIndexSize = reusedIndexSize;
this.recoveredIndexSize = recoveredIndexSize;
this.recoveredTranslogOperations = recoveredTranslogOperations;
}

public Stage stage() {
return this.stage;
}

public long startTime() {
return this.startTime;
}

public long getStartTime() {
return this.startTime;
}

public TimeValue time() {
return TimeValue.timeValueMillis(time);
}

public TimeValue getTime() {
return time();
}

public TimeValue throttlingTime() {
return TimeValue.timeValueMillis(throttlingTime);
}

public TimeValue getThrottlingTime() {
return throttlingTime();
}

public TimeValue indexThrottlingTime() {
return TimeValue.timeValueMillis(indexThrottlingTime);
}

public TimeValue getIndexThrottlingTime() {
return indexThrottlingTime();
}

public ByteSizeValue indexSize() {
return new ByteSizeValue(indexSize);
}

public ByteSizeValue getIndexSize() {
return indexSize();
}

public ByteSizeValue reusedIndexSize() {
return new ByteSizeValue(reusedIndexSize);
}

public ByteSizeValue getReusedIndexSize() {
return reusedIndexSize();
}

public ByteSizeValue expectedRecoveredIndexSize() {
return new ByteSizeValue(indexSize - reusedIndexSize);
}

public ByteSizeValue getExpectedRecoveredIndexSize() {
return expectedRecoveredIndexSize();
}

/**
* How much of the index has been recovered.
*/
public ByteSizeValue recoveredIndexSize() {
return new ByteSizeValue(recoveredIndexSize);
}

/**
* How much of the index has been recovered.
*/
public ByteSizeValue getRecoveredIndexSize() {
return recoveredIndexSize();
}

public long recoveredTranslogOperations() {
return recoveredTranslogOperations;
}

public long getRecoveredTranslogOperations() {
return recoveredTranslogOperations();
}
}
@@ -0,0 +1,168 @@
/*
* Licensed to Elastic Search and Shay Banon under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. Elastic Search 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.elasticsearch.action.admin.indices.status;

import org.elasticsearch.ElasticSearchIllegalArgumentException;
import org.elasticsearch.common.unit.ByteSizeValue;
import org.elasticsearch.common.unit.TimeValue;

/**
* @author kimchy (shay.banon)
*/
public class PeerRecoveryStatus {

public enum Stage {
INIT((byte) 0),
RETRY((byte) 1),
INDEX((byte) 2),
TRANSLOG((byte) 3),
FINALIZE((byte) 4),
DONE((byte) 5);

private final byte value;

Stage(byte value) {
this.value = value;
}

public byte value() {
return value;
}

public static Stage fromValue(byte value) {
if (value == 0) {
return INIT;
} else if (value == 1) {
return RETRY;
} else if (value == 2) {
return INDEX;
} else if (value == 3) {
return TRANSLOG;
} else if (value == 4) {
return FINALIZE;
} else if (value == 5) {
return DONE;
}
throw new ElasticSearchIllegalArgumentException("No stage found for [" + value + ']');
}
}

final Stage stage;

final long startTime;

final long time;

final long throttlingTime;

final long indexSize;

final long reusedIndexSize;

final long recoveredIndexSize;

final long recoveredTranslogOperations;

public PeerRecoveryStatus(Stage stage, long startTime, long time, long throttlingTime, long indexSize, long reusedIndexSize,
long recoveredIndexSize, long recoveredTranslogOperations) {
this.stage = stage;
this.startTime = startTime;
this.time = time;
this.throttlingTime = throttlingTime;
this.indexSize = indexSize;
this.reusedIndexSize = reusedIndexSize;
this.recoveredIndexSize = recoveredIndexSize;
this.recoveredTranslogOperations = recoveredTranslogOperations;
}

public Stage stage() {
return this.stage;
}

public long startTime() {
return this.startTime;
}

public long getStartTime() {
return this.startTime;
}

public TimeValue time() {
return TimeValue.timeValueMillis(time);
}

public TimeValue getTime() {
return time();
}

public TimeValue throttlingTime() {
return TimeValue.timeValueMillis(throttlingTime);
}

public TimeValue getThrottlingTime() {
return throttlingTime();
}

public ByteSizeValue indexSize() {
return new ByteSizeValue(indexSize);
}

public ByteSizeValue getIndexSize() {
return indexSize();
}

public ByteSizeValue reusedIndexSize() {
return new ByteSizeValue(reusedIndexSize);
}

public ByteSizeValue getReusedIndexSize() {
return reusedIndexSize();
}

public ByteSizeValue expectedRecoveredIndexSize() {
return new ByteSizeValue(indexSize - reusedIndexSize);
}

public ByteSizeValue getExpectedRecoveredIndexSize() {
return expectedRecoveredIndexSize();
}

/**
* How much of the index has been recovered.
*/
public ByteSizeValue recoveredIndexSize() {
return new ByteSizeValue(recoveredIndexSize);
}

/**
* How much of the index has been recovered.
*/
public ByteSizeValue getRecoveredIndexSize() {
return recoveredIndexSize();
}

public long recoveredTranslogOperations() {
return recoveredTranslogOperations;
}

public long getRecoveredTranslogOperations() {
return recoveredTranslogOperations();
}
}

0 comments on commit 3f9034b

Please sign in to comment.