Class Proctor


  • public class Proctor
    extends java.lang.Object
    The sole entry point for client applications determining the test buckets for a particular client. Basically a Factory to create ProctorResult for a given identifier and context, based on a TestMatrix and a specification. Supposedly immutable result of loading a test matrix, so each reload creates a new instance of this class.

    See determineTestGroups(Identifiers, Map, Map)

    • Field Detail

      • EMPTY

        public static final Proctor EMPTY
    • Method Detail

      • determineTestGroups

        @Nonnull
        @Deprecated
        public ProctorResult determineTestGroups​(TestType testType,
                                                 java.lang.String identifier,
                                                 @Nonnull
                                                 java.util.Map<java.lang.String,​java.lang.Object> context,
                                                 @Nonnull
                                                 java.util.Map<java.lang.String,​java.lang.Integer> forceGroups)
        Determine which test buckets apply to a particular client.
        Parameters:
        testType - the TestType of the test
        identifier - a unique-ish String identifying the client. This should be consistent across requests from the same client.
        context - a Map containing variables describing the context in which the request is executing. These will be supplied to any rules that execute to determine test eligibility.
        forceGroups - a Map from a String test name to an Integer bucket value. For the specified test allocate the specified bucket (if valid) regardless of the standard logic
        Returns:
        a ProctorResult containing the test buckets that apply to this client as well as the versions of the tests that were executed
      • determineTestGroups

        @Nonnull
        @Deprecated
        public ProctorResult determineTestGroups​(@Nonnull
                                                 Identifiers identifiers,
                                                 @Nonnull
                                                 java.util.Map<java.lang.String,​java.lang.Object> inputContext,
                                                 @Nonnull
                                                 java.util.Map<java.lang.String,​java.lang.Integer> forceGroups)
        Determine which test buckets apply to a particular client.
        Parameters:
        identifiers - a Map of unique-ish Strings describing the request in the context of different TestTypes.For example, TestType.USER has a CTK associated, TestType.EMAIL is an email address, TestType.PAGE might be a url-encoded String containing the normalized relevant page parameters
        inputContext - a Map containing variables describing the context in which the request is executing. These will be supplied to any rules that execute to determine test eligibility.
        forceGroups - a Map from a String test name to an Integer bucket value. For the specified test allocate the specified bucket (if valid) regardless of the standard logic
        Returns:
        a ProctorResult containing the test buckets that apply to this client as well as the versions of the tests that were executed
      • determineTestGroups

        @Nonnull
        public ProctorResult determineTestGroups​(@Nonnull
                                                 Identifiers identifiers,
                                                 @Nonnull
                                                 java.util.Map<java.lang.String,​java.lang.Object> inputContext,
                                                 @Nonnull
                                                 ForceGroupsOptions forceGroupsOptions,
                                                 @Nonnull
                                                 java.util.Collection<java.lang.String> testNameFilter)
        See determineTestGroups() above. Adds a test name filter for returning a subset of tests. This is useful for the Proctor REST API. It lacks a specification and needs a way to evaluate only the tests mentioned in the HTTP parameters by each particular query. Otherwise, there will be logged errors due to missing context variables.
        Parameters:
        identifiers - a Map of unique-ish Strings describing the request in the context of different TestTypes.For example, TestType.USER has a CTK associated, TestType.EMAIL is an email address, TestType.PAGE might be a url-encoded String containing the normalized relevant page parameters
        inputContext - a Map containing variables describing the context in which the request is executing. These will be supplied to any rules that execute to determine test eligibility.
        forceGroupsOptions - a Map from a String test name to an Integer bucket value. For the specified test allocate the specified bucket (if valid) regardless of the standard logic
        testNameFilter - Only evaluates and returns the tests named in this collection. If empty, no filter is applied.
        Returns:
        a ProctorResult containing the test buckets that apply to this client as well as the versions of the tests that were executed
      • getTestNames

        public java.util.Set<java.lang.String> getTestNames()
      • appendAllTests

        public void appendAllTests​(java.io.Writer sb)
      • appendTests

        public void appendTests​(java.io.Writer sb,
                                TestType type)
      • appendTestsNameFiltered

        public void appendTestsNameFiltered​(java.io.Writer sb,
                                            java.util.Collection<java.lang.String> testNameFilter)
      • appendTests

        public void appendTests​(java.io.Writer sb,
                                @Nonnull
                                com.google.common.base.Predicate<com.indeed.proctor.common.TestChooser<?>> shouldIncludeTest)
      • appendTestMatrix

        public void appendTestMatrix​(java.io.Writer writer)
                              throws java.io.IOException
        appends json representation of testmatrix. Does not close the writer.
        Throws:
        java.io.IOException
      • appendTestMatrixFiltered

        public void appendTestMatrixFiltered​(java.io.Writer writer,
                                             java.util.Collection<java.lang.String> testNameFilter)
                                      throws java.io.IOException
        appends json representation of testmatrix with only given testnames. Does not close the writer.
        Throws:
        java.io.IOException