Skip to content
Snippets Groups Projects
Commit 4823a07d authored by Josh Elser's avatar Josh Elser Committed by Josh Elser
Browse files

[core] Treat BATCHED_OK as an acceptable status for insert()

parent 5dc57b77
No related branches found
No related tags found
No related merge requests found
/**
* Copyright (c) 2010 Yahoo! Inc. All rights reserved.
* Copyright (c) 2010 Yahoo! Inc., 2016 YCSB contributors. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you
* may not use this file except in compliance with the License. You
......@@ -184,7 +184,7 @@ public class DBWrapper extends DB
private void measure(String op, Status result, long intendedStartTimeNanos,
long startTimeNanos, long endTimeNanos) {
String measurementName = op;
if (result != Status.OK) {
if (result == null || !result.isOk()) {
if (this.reportLatencyForEachError ||
this.latencyTrackedErrors.contains(result.getName())) {
measurementName = op + "-" + result.getName();
......
/**
* Copyright (c) 2015 YCSB contributors All rights reserved.
* Copyright (c) 2016 YCSB contributors All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you
* may not use this file except in compliance with the License. You
......@@ -79,6 +79,14 @@ public class Status {
return true;
}
/**
* Is {@code this} a passing state for the operation: {@link Status#OK} or {@link Status#BATCHED_OK}.
* @return true if the operation is successful, false otherwise
*/
public boolean isOk() {
return this == OK || this == BATCHED_OK;
}
public static final Status OK = new Status("OK", "The operation completed successfully.");
public static final Status ERROR = new Status("ERROR", "The operation failed.");
public static final Status NOT_FOUND = new Status("NOT_FOUND", "The requested record was not found.");
......
......@@ -41,6 +41,7 @@ import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Vector;
......@@ -590,7 +591,7 @@ public class CoreWorkload extends Workload {
int numOfRetries = 0;
do {
status = db.insert(table, dbkey, values);
if (status == Status.OK) {
if (null != status && status.isOk()) {
break;
}
// Retry if configured. Without retrying, the load process will fail
......@@ -614,7 +615,7 @@ public class CoreWorkload extends Workload {
}
} while (true);
return (status == Status.OK);
return null != status && status.isOk();
}
/**
......
/**
* Copyright (c) 2016 YCSB contributors. All rights reserved.
*
* Licensed 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. See accompanying
* LICENSE file.
*/
package com.yahoo.ycsb;
import org.testng.annotations.Test;
import static org.testng.Assert.assertFalse;
import static org.testng.Assert.assertTrue;
/**
* Test class for {@link Status}.
*/
public class TestStatus {
@Test
public void testAcceptableStatus() {
assertTrue(Status.OK.isOk());
assertTrue(Status.BATCHED_OK.isOk());
assertFalse(Status.BAD_REQUEST.isOk());
assertFalse(Status.ERROR.isOk());
assertFalse(Status.FORBIDDEN.isOk());
assertFalse(Status.NOT_FOUND.isOk());
assertFalse(Status.NOT_IMPLEMENTED.isOk());
assertFalse(Status.SERVICE_UNAVAILABLE.isOk());
assertFalse(Status.UNEXPECTED_STATE.isOk());
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment