mirror of
https://github.com/google/nomulus.git
synced 2025-05-31 17:54:08 +02:00
Prober circular list (#218)
* Fixed changes suggested by CydeWeys * Fixed Javadoc and comments for ActionHandler * Fixed comments and JavaDoc on other files * EOL added * Removed Unnecessary Files * fixed .gradle files styles * Removed outbound message from ActionHandler's fields and renamed Marker Interfaces * Fixed javadoc for Marker Interfaced * Modified Comments on ActionHandler * Removed LocalAddress from Protocol * Fixed Travis Build Issues * Rebased to Master and added in modified Handlers and ProbingAction * Added missing license headers and JavaDoc * Minor fix in NewChannelAction JavaDoc * Minor Style Fix * Full WebWhoIs Sequence Added * fixed build issues * Refactored by responses suggested by jianglai. * Minor Style Fixes * Updated build.gradle file * Modified license header dates * Updated WebWhois tests. * Refactored WebWhois to accomodate jianglai's suggested changes and modified tests to reflect this refactoring * SpotlessApply run to fix style issues * Added license header and newline where appropriate. * Javadoc style fix in tests and removed unused methods * Refactored ProbingAction to minimize number of unnecessary methods * Initial Commit. * Initial Commit. * Deleted unfinished features. Added ActionHandler and its Unit Tests. * Included prober subproject in settings.gradle * Added Protocol Class and its Basic Unit Tests * Added Protocol Class and its Basic Unit Tests * Added Changes Suggested by jianglai * Fixed Gitignore to take out AutoValue generated code * Fixed Gitignore to take out AutoValue generated code * Removed AutoValue java files * Added gitignore within prober * Removed all generated java * Final Changes in .gitignore * Final Changes in .gitignore * Added Ssl and WebWhois Action Handlers and their unit tests in addition to the ProbingAction class * Fixed build.gradle changes requested * Removed Files irrelevant to current pull request * Fixed changes suggested by CydeWeys * Fixed changes suggested by CydeWeys * Fixed changes suggested by CydeWeys * Fixed changes suggested by CydeWeys * Minor fixes to ActionHandler, as responded in comments, removed package-info, and updated settings.gradle * Minor fixes to ActionHandler, as responded in comments, removed package-info, and updated settings.gradle * Fully Updated ActionHandler (missing updated JavaDoc) * Added changed Protocol and both Inbound and Outbound Markers * Removed AutoVaue ignore clause from .gitignore * Removed AutoVaue ignore clause from .gitignore * removed unneccessary dependencies in build.gradle * Fixed Javadoc and comments for ActionHandler * Fixed comments and JavaDoc on other files * EOL added * Removed Unnecessary Files * fixed .gradle files styles * Removed outbound message from ActionHandler's fields and renamed Marker Interfaces * Fixed javadoc for Marker Interfaced * Modified Comments on ActionHandler * Removed LocalAddress from Protocol * Fixed Travis Build Issues * Rebased to Master and added in modified Handlers and ProbingAction * Rebased to Master and added in modified Handlers and ProbingAction * Rebased to Master and added in modified Handlers and ProbingAction * Rebased to Master and added in modified Handlers and ProbingAction * Rebased to Master and added in modified Handlers and ProbingAction * Added missing license headers and JavaDoc * Added missing license headers and JavaDoc * Added missing license headers and JavaDoc * Added missing license headers and JavaDoc * Added missing license headers and JavaDoc * Minor fix in NewChannelAction JavaDoc * Minor fix in NewChannelAction JavaDoc * Minor fix in NewChannelAction JavaDoc * Minor fix in NewChannelAction JavaDoc * Minor fix in NewChannelAction JavaDoc * Minor Style Fix * Minor Style Fix * Minor Style Fix * Minor Style Fix * Full WebWhoIs Sequence Added * Full WebWhoIs Sequence Added * Full WebWhoIs Sequence Added * Full WebWhoIs Sequence Added * Full WebWhoIs Sequence Added * Full WebWhoIs Sequence Added * fixed build issues * fixed build issues * fixed build issues * fixed build issues * fixed build issues * Refactored by responses suggested by jianglai. * Refactored by responses suggested by jianglai. * Refactored by responses suggested by jianglai. * Refactored by responses suggested by jianglai. * Refactored by responses suggested by jianglai. * Refactored by responses suggested by jianglai. * Minor Style Fixes * Minor Style Fixes * Minor Style Fixes * Minor Style Fixes * Minor Style Fixes * Updated build.gradle file * Updated build.gradle file * Updated build.gradle file * Updated build.gradle file * Modified license header dates * Modified license header dates * Modified license header dates * Modified license header dates * Modified license header dates * Updated WebWhois tests. * Updated WebWhois tests. * Updated WebWhois tests. * Updated WebWhois tests. * Refactored WebWhois to accomodate jianglai's suggested changes and modified tests to reflect this refactoring * Refactored WebWhois to accomodate jianglai's suggested changes and modified tests to reflect this refactoring * Refactored WebWhois to accomodate jianglai's suggested changes and modified tests to reflect this refactoring * Refactored WebWhois to accomodate jianglai's suggested changes and modified tests to reflect this refactoring * Refactored WebWhois to accomodate jianglai's suggested changes and modified tests to reflect this refactoring * Refactored WebWhois to accomodate jianglai's suggested changes and modified tests to reflect this refactoring * SpotlessApply run to fix style issues * SpotlessApply run to fix style issues * SpotlessApply run to fix style issues * SpotlessApply run to fix style issues * SpotlessApply run to fix style issues * Added license header and newline where appropriate. * Added license header and newline where appropriate. * Added license header and newline where appropriate. * Added license header and newline where appropriate. * Added license header and newline where appropriate. * Javadoc style fix in tests and removed unused methods * Javadoc style fix in tests and removed unused methods * Javadoc style fix in tests and removed unused methods * Javadoc style fix in tests and removed unused methods * Javadoc style fix in tests and removed unused methods * Refactored ProbingAction to minimize number of unnecessary methods * Refactored ProbingAction to minimize number of unnecessary methods * Refactored ProbingAction to minimize number of unnecessary methods * Refactored ProbingAction to minimize number of unnecessary methods * Modified tests for WebWhois according to changes suggested by laijiang. * Modified tests for WebWhois according to changes suggested by laijiang. * Modified tests for WebWhois according to changes suggested by laijiang. * Modified tests for WebWhois according to changes suggested by laijiang. * Modified tests for WebWhois according to changes suggested by laijiang. * Removed TestProvider from TestUtils. * Removed TestProvider from TestUtils. * Removed TestProvider from TestUtils. * Removed TestProvider from TestUtils. * Removed TestProvider from TestUtils. * Rebased to master * Rebased to master * Updated issues in rebasing * Updated issues in rebasing * Minor style change on prober/build.gradle * Minor style change on prober/build.gradle * Fixed warnings for java compilation * Fixed warnings for java compilation * Fixed files to pass all style tests * Fixed files to pass all style tests * Fixed files to pass all style tests * Minor syle fixes after succesful rebase onto master * Fixed changes suggested by CydeWeys * Fixed changes suggested by CydeWeys * Fixed changes suggested by CydeWeys * Rebased to Master and added in modified Handlers and ProbingAction * Rebased to Master and added in modified Handlers and ProbingAction * Rebased to Master and added in modified Handlers and ProbingAction * Added missing license headers and JavaDoc * Added missing license headers and JavaDoc * Added missing license headers and JavaDoc * Minor fix in NewChannelAction JavaDoc * Minor fix in NewChannelAction JavaDoc * Minor fix in NewChannelAction JavaDoc * Minor Style Fix * Minor Style Fix * Minor Style Fix * Full WebWhoIs Sequence Added * Full WebWhoIs Sequence Added * Full WebWhoIs Sequence Added * fixed build issues * fixed build issues * fixed build issues * Refactored by responses suggested by jianglai. * Refactored by responses suggested by jianglai. * Refactored by responses suggested by jianglai. * Minor Style Fixes * Minor Style Fixes * Updated build.gradle file * Updated build.gradle file * Updated build.gradle file * Modified license header dates * Modified license header dates * Modified license header dates * Updated WebWhois tests. * Updated WebWhois tests. * Updated WebWhois tests. * Refactored WebWhois to accomodate jianglai's suggested changes and modified tests to reflect this refactoring * Refactored WebWhois to accomodate jianglai's suggested changes and modified tests to reflect this refactoring * SpotlessApply run to fix style issues * Added circular linked list to utils * Added circular linked list to utils * Added circular linked list to utils * Added circular linked list to utils * Added circular linked list to utils * License Header added * License Header added * License Header added * License Header added * License Header added * Added license header and newline where appropriate. * Added license header and newline where appropriate. * Refactored probing sequence to be circular linked list iterator * Refactored probing sequence to be circular linked list iterator * Refactored probing sequence to be circular linked list iterator * Refactored probing sequence to be circular linked list iterator * Javadoc style fix in tests and removed unused methods * Javadoc style fix in tests and removed unused methods * Javadoc style fix in tests and removed unused methods * Modified ProbingStep tests to reflect new ProbingStep structure. * Modified ProbingStep tests to reflect new ProbingStep structure. * Refactored ProbingAction to minimize number of unnecessary methods * Refactored ProbingAction to minimize number of unnecessary methods * Refactored ProbingAction to minimize number of unnecessary methods * Modified tests for WebWhois according to changes suggested by laijiang. * Modified tests for WebWhois according to changes suggested by laijiang. * Modified tests for WebWhois according to changes suggested by laijiang. * Removed TestProvider from TestUtils. * Removed TestProvider from TestUtils. * Rebased to master * ProbingStepTest modified to have fewer unnecessary helper methods * ProbingStepTest modified to have fewer unnecessary helper methods * Updated issues in rebasing * Updated issues in rebasing * Added missing license header to DefaultCircularLinkedListIterator * Fixed max column length to be 100 * Fixed max column length to be 100 * Minor changes to pass style tests * Successful rebase onto finished web-whois branch * Removed need for TestTokens with Mockito mocks of Tokens * Fixed style issues in DefaultCircularLinkedListIterator and AbstractCircularLinkedListIterator * Modified CircularList according to changes suggested by jianglai. * Merge branch 'master' into prober-circular-list * Modified ProbingSequenceTest to not expect unnecessary NullPointerException * ProbingSequence and tests modified to reflect addition of UnrecoverableStateException and restarts on failures * Modified ProbingSequence and its tests to reflect action generation and calling being put in the same try catch block
This commit is contained in:
parent
5b2ce06b79
commit
02c2b37fe3
10 changed files with 697 additions and 281 deletions
146
util/src/main/java/google/registry/util/CircularList.java
Normal file
146
util/src/main/java/google/registry/util/CircularList.java
Normal file
|
@ -0,0 +1,146 @@
|
|||
// Copyright 2019 The Nomulus Authors. 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.
|
||||
|
||||
package google.registry.util;
|
||||
|
||||
/**
|
||||
* Class that stores value {@param <T>}, and points in circle to other {@link CircularList}
|
||||
* objects.
|
||||
*
|
||||
* @param <T> - Element type stored in the {@link CircularList}
|
||||
*
|
||||
* <p>In its construction, we create a sequence of {@link CircularList} objects, each storing an
|
||||
* instance of T. They each point to each other in a circular manner, such that we can perform
|
||||
* circular iteration on the elements. Once finished building, we return this first {@link
|
||||
* CircularList} object in the sequence.</p>
|
||||
*/
|
||||
public class CircularList<T> {
|
||||
|
||||
/**
|
||||
* T instance stored in current node of list.
|
||||
*/
|
||||
private final T value;
|
||||
|
||||
/**
|
||||
* Pointer to next node of list.
|
||||
*/
|
||||
private CircularList<T> next;
|
||||
|
||||
/**
|
||||
* Standard constructor for {@link CircularList} that initializes its stored {@code value}.
|
||||
*/
|
||||
protected CircularList(T value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Standard get method to retrieve {@code value}.
|
||||
*/
|
||||
public T get() {
|
||||
return value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Standard method to obtain {@code next} node in list.
|
||||
*/
|
||||
public CircularList<T> next() {
|
||||
return next;
|
||||
}
|
||||
|
||||
/**
|
||||
* Setter method only used in builder to point one node to the next.
|
||||
*/
|
||||
public void setNext(CircularList<T> next) {
|
||||
this.next = next;
|
||||
}
|
||||
|
||||
/**
|
||||
* Default Builder to create a standard instance of a {@link CircularList}.
|
||||
*/
|
||||
public static class Builder<T> extends AbstractBuilder<T, CircularList<T>> {
|
||||
|
||||
/**
|
||||
* Simply calls on constructor to {@link CircularList} to create new instance.
|
||||
*/
|
||||
@Override
|
||||
protected CircularList<T> create(T value) {
|
||||
return new CircularList<>(value);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* As {@link CircularList} represents one component of the entire list, it requires a builder to
|
||||
* create the full list.
|
||||
*
|
||||
* @param <T> - Matching element type of iterator
|
||||
*
|
||||
* <p>Supports adding in element at a time, adding an {@link Iterable}
|
||||
* of elements, and adding an variable number of elemetns.</p>
|
||||
*
|
||||
* <p>Sets first element added to {@code first}, and when built, points last element to the
|
||||
* {@code first} element.</p>
|
||||
*/
|
||||
public abstract static class AbstractBuilder<T, C extends CircularList<T>> {
|
||||
|
||||
protected C first;
|
||||
protected C current;
|
||||
|
||||
/**
|
||||
* Necessary to instantiate each {@code C} object from {@code value}.
|
||||
*/
|
||||
protected abstract C create(T value);
|
||||
|
||||
/**
|
||||
* Sets current {@code C} to element added and points previous {@code C} to this one.
|
||||
*/
|
||||
public AbstractBuilder<T, C> add(T value) {
|
||||
C c = create(value);
|
||||
if (current == null) {
|
||||
first = c;
|
||||
} else {
|
||||
current.setNext(c);
|
||||
}
|
||||
current = c;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Simply calls {@code addElement}, for each element in {@code elements}.
|
||||
*/
|
||||
public AbstractBuilder<T, C> add(T... values) {
|
||||
for (T element : values) {
|
||||
add(element);
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Simply calls {@code addElement}, for each element in {@code elements}.
|
||||
*/
|
||||
public AbstractBuilder<T, C> add(Iterable<T> values) {
|
||||
values.forEach(this::add);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the next {@code C} of the list to be the first {@code C} in the list.
|
||||
*/
|
||||
public C build() {
|
||||
current.setNext(first);
|
||||
return first;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue