Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[FLINK-5107] Introduced limit for prior execution attempt history
This closes #2837.
- Loading branch information
1 parent
ba8ed26
commit f5af7f1
Showing
8 changed files
with
422 additions
and
23 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
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
38 changes: 38 additions & 0 deletions
38
flink-runtime/src/main/java/org/apache/flink/runtime/jobmanager/JobManagerOptions.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 | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,38 @@ | |||
/* | |||
* Licensed to the Apache Software Foundation (ASF) under one | |||
* or more contributor license agreements. See the NOTICE file | |||
* distributed with this work for additional information | |||
* regarding copyright ownership. The ASF 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.apache.flink.runtime.jobmanager; | |||
|
|||
import org.apache.flink.annotation.PublicEvolving; | |||
import org.apache.flink.configuration.ConfigOption; | |||
|
|||
import static org.apache.flink.configuration.ConfigOptions.key; | |||
|
|||
@PublicEvolving | |||
public class JobManagerOptions { | |||
|
|||
/** | |||
* The maximum number of prior execution attempts kept in history. | |||
*/ | |||
public static final ConfigOption<Integer> MAX_ATTEMPTS_HISTORY_SIZE = | |||
key("job-manager.max-attempts-history-size").defaultValue(16); | |||
|
|||
private JobManagerOptions() { | |||
throw new IllegalAccessError(); | |||
} | |||
} |
160 changes: 160 additions & 0 deletions
160
flink-runtime/src/main/java/org/apache/flink/runtime/util/EvictingBoundedList.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 | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,160 @@ | |||
/* | |||
* Licensed to the Apache Software Foundation (ASF) under one | |||
* or more contributor license agreements. See the NOTICE file | |||
* distributed with this work for additional information | |||
* regarding copyright ownership. The ASF 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.apache.flink.runtime.util; | |||
|
|||
import org.apache.flink.util.Preconditions; | |||
|
|||
import java.io.Serializable; | |||
import java.util.ConcurrentModificationException; | |||
import java.util.Iterator; | |||
import java.util.NoSuchElementException; | |||
|
|||
/** | |||
* This class implements a list (array based) that is physically bounded in maximum size, but can virtually grow beyond | |||
* the bounded size. When the list grows beyond the size bound, elements are dropped from the head of the list (FIFO | |||
* order). If dropped elements are accessed, a default element is returned instead. | |||
* <p> | |||
* TODO this class could eventually implement the whole actual List interface. | |||
* | |||
* @param <T> type of the list elements | |||
*/ | |||
public class EvictingBoundedList<T> implements Iterable<T>, Serializable { | |||
|
|||
private static final long serialVersionUID = -1863961980953613146L; | |||
|
|||
private final T defaultElement; | |||
private final Object[] elements; | |||
private int idx; | |||
private int count; | |||
private long modCount; | |||
|
|||
public EvictingBoundedList(int sizeLimit) { | |||
this(sizeLimit, null); | |||
} | |||
|
|||
public EvictingBoundedList(EvictingBoundedList<T> other) { | |||
Preconditions.checkNotNull(other); | |||
this.defaultElement = other.defaultElement; | |||
this.elements = other.elements.clone(); | |||
this.idx = other.idx; | |||
this.count = other.count; | |||
this.modCount = 0L; | |||
} | |||
|
|||
public EvictingBoundedList(int sizeLimit, T defaultElement) { | |||
this.elements = new Object[sizeLimit]; | |||
this.defaultElement = defaultElement; | |||
this.idx = 0; | |||
this.count = 0; | |||
this.modCount = 0L; | |||
} | |||
|
|||
public int size() { | |||
return count; | |||
} | |||
|
|||
public boolean isEmpty() { | |||
return 0 == count; | |||
} | |||
|
|||
public boolean add(T t) { | |||
elements[idx] = t; | |||
idx = (idx + 1) % elements.length; | |||
++count; | |||
++modCount; | |||
return true; | |||
} | |||
|
|||
public void clear() { | |||
if (!isEmpty()) { | |||
for (int i = 0; i < elements.length; ++i) { | |||
elements[i] = null; | |||
} | |||
count = 0; | |||
idx = 0; | |||
++modCount; | |||
} | |||
} | |||
|
|||
public T get(int index) { | |||
Preconditions.checkArgument(index >= 0 && index < count); | |||
return isDroppedIndex(index) ? getDefaultElement() : accessInternal(index % elements.length); | |||
} | |||
|
|||
public int getSizeLimit() { | |||
return elements.length; | |||
} | |||
|
|||
public T set(int index, T element) { | |||
Preconditions.checkArgument(index >= 0 && index < count); | |||
++modCount; | |||
if (isDroppedIndex(index)) { | |||
return getDefaultElement(); | |||
} else { | |||
int idx = index % elements.length; | |||
T old = accessInternal(idx); | |||
elements[idx] = element; | |||
return old; | |||
} | |||
} | |||
|
|||
public T getDefaultElement() { | |||
return defaultElement; | |||
} | |||
|
|||
private boolean isDroppedIndex(int idx) { | |||
return idx < count - elements.length; | |||
} | |||
|
|||
@SuppressWarnings("unchecked") | |||
private T accessInternal(int arrayIndex) { | |||
return (T) elements[arrayIndex]; | |||
} | |||
|
|||
@Override | |||
public Iterator<T> iterator() { | |||
return new Iterator<T>() { | |||
|
|||
int pos = 0; | |||
final long oldModCount = modCount; | |||
|
|||
@Override | |||
public boolean hasNext() { | |||
return pos < count; | |||
} | |||
|
|||
@Override | |||
public T next() { | |||
if (oldModCount != modCount) { | |||
throw new ConcurrentModificationException(); | |||
} | |||
if (pos < count) { | |||
return get(pos++); | |||
} else { | |||
throw new NoSuchElementException("Iterator exhausted."); | |||
} | |||
} | |||
|
|||
@Override | |||
public void remove() { | |||
throw new UnsupportedOperationException("Read-only iterator"); | |||
} | |||
}; | |||
} | |||
} |
Oops, something went wrong.