Search in sources :

Example 16 with Sets

use of org.apache.flink.shaded.guava30.com.google.common.collect.Sets in project incubator-pulsar by apache.

the class BrokerServiceLookupTest method testSplitUnloadLookupTest.

/**
 * <pre>
 * When broker-1's load-manager splits the bundle and update local-policies, broker-2 should get watch of
 * local-policies and update bundleCache so, new lookup can be redirected properly.
 *
 * (1) Start broker-1 and broker-2
 * (2) Make sure broker-2 always assign bundle to broker1
 * (3) Broker-2 receives topic-1 request, creates local-policies and sets the watch
 * (4) Broker-1 will own topic-1
 * (5) Split the bundle for topic-1
 * (6) Broker-2 should get the watch and update bundle cache
 * (7) Make lookup request again to Broker-2 which should succeed.
 *
 * </pre>
 *
 * @throws Exception
 */
@Test(timeOut = 5000)
public void testSplitUnloadLookupTest() throws Exception {
    log.info("-- Starting {} test --", methodName);
    final String namespace = "my-property/use/my-ns";
    // (1) Start broker-1
    ServiceConfiguration conf2 = new ServiceConfiguration();
    conf2.setAdvertisedAddress("localhost");
    conf2.setBrokerServicePort(PortManager.nextFreePort());
    conf2.setBrokerServicePortTls(PortManager.nextFreePort());
    conf2.setWebServicePort(PortManager.nextFreePort());
    conf2.setWebServicePortTls(PortManager.nextFreePort());
    conf2.setAdvertisedAddress("localhost");
    conf2.setClusterName(conf.getClusterName());
    conf2.setZookeeperServers("localhost:2181");
    PulsarService pulsar2 = startBroker(conf2);
    pulsar.getLoadManager().get().writeLoadReportOnZookeeper();
    pulsar2.getLoadManager().get().writeLoadReportOnZookeeper();
    pulsar.getLoadManager().get().writeLoadReportOnZookeeper();
    pulsar2.getLoadManager().get().writeLoadReportOnZookeeper();
    LoadManager loadManager1 = spy(pulsar.getLoadManager().get());
    LoadManager loadManager2 = spy(pulsar2.getLoadManager().get());
    Field loadManagerField = NamespaceService.class.getDeclaredField("loadManager");
    loadManagerField.setAccessible(true);
    // (2) Make sure broker-2 always assign bundle to broker1
    // mock: redirect request to leader [2]
    doReturn(true).when(loadManager2).isCentralized();
    loadManagerField.set(pulsar2.getNamespaceService(), new AtomicReference<>(loadManager2));
    // mock: return Broker1 as a Least-loaded broker when leader receies request [3]
    doReturn(true).when(loadManager1).isCentralized();
    SimpleResourceUnit resourceUnit = new SimpleResourceUnit(pulsar.getWebServiceAddress(), null);
    doReturn(Optional.of(resourceUnit)).when(loadManager1).getLeastLoaded(any(ServiceUnitId.class));
    loadManagerField.set(pulsar.getNamespaceService(), new AtomicReference<>(loadManager1));
    URI broker2ServiceUrl = new URI("pulsar://localhost:" + conf2.getBrokerServicePort());
    PulsarClient pulsarClient2 = PulsarClient.builder().serviceUrl(broker2ServiceUrl.toString()).build();
    // (3) Broker-2 receives topic-1 request, creates local-policies and sets the watch
    final String topic1 = "persistent://" + namespace + "/topic1";
    Consumer<byte[]> consumer1 = pulsarClient2.newConsumer().topic(topic1).subscriptionName("my-subscriber-name").subscribe();
    Set<String> serviceUnits1 = pulsar.getNamespaceService().getOwnedServiceUnits().stream().map(nb -> nb.toString()).collect(Collectors.toSet());
    // (4) Broker-1 will own topic-1
    final String unsplitBundle = namespace + "/0x00000000_0xffffffff";
    assertTrue(serviceUnits1.contains(unsplitBundle));
    // broker-2 should have this bundle into the cache
    TopicName topicName = TopicName.get(topic1);
    NamespaceBundle bundleInBroker2 = pulsar2.getNamespaceService().getBundle(topicName);
    assertEquals(bundleInBroker2.toString(), unsplitBundle);
    // (5) Split the bundle for topic-1
    admin.namespaces().splitNamespaceBundle(namespace, "0x00000000_0xffffffff", true);
    // (6) Broker-2 should get the watch and update bundle cache
    final int retry = 5;
    for (int i = 0; i < retry; i++) {
        if (pulsar2.getNamespaceService().getBundle(topicName).equals(bundleInBroker2) && i != retry - 1) {
            Thread.sleep(200);
        } else {
            break;
        }
    }
    // (7) Make lookup request again to Broker-2 which should succeed.
    final String topic2 = "persistent://" + namespace + "/topic2";
    Consumer<byte[]> consumer2 = pulsarClient.newConsumer().topic(topic2).subscriptionName("my-subscriber-name").subscribe();
    NamespaceBundle bundleInBroker1AfterSplit = pulsar2.getNamespaceService().getBundle(TopicName.get(topic2));
    assertFalse(bundleInBroker1AfterSplit.equals(unsplitBundle));
    consumer1.close();
    consumer2.close();
    pulsarClient2.close();
    pulsar2.close();
}
Also used : HttpURLConnection(java.net.HttpURLConnection) SSLContext(javax.net.ssl.SSLContext) URL(java.net.URL) DiscoveryService(org.apache.pulsar.discovery.service.DiscoveryService) Request(org.asynchttpclient.Request) ObjectMapperFactory(org.apache.pulsar.common.util.ObjectMapperFactory) LoggerFactory(org.slf4j.LoggerFactory) TrustManager(javax.net.ssl.TrustManager) Cleanup(lombok.Cleanup) LoadManager(org.apache.pulsar.broker.loadbalance.LoadManager) Test(org.testng.annotations.Test) ClusterData(org.apache.pulsar.common.policies.data.ClusterData) PortManager(org.apache.bookkeeper.test.PortManager) AfterMethod(org.testng.annotations.AfterMethod) AuthenticationException(javax.naming.AuthenticationException) SecureRandom(java.security.SecureRandom) AsyncHttpClientConfig(org.asynchttpclient.AsyncHttpClientConfig) Map(java.util.Map) DefaultAsyncHttpClientConfig(org.asynchttpclient.DefaultAsyncHttpClientConfig) URI(java.net.URI) Mockito.doReturn(org.mockito.Mockito.doReturn) Assert.assertFalse(org.testng.Assert.assertFalse) Method(java.lang.reflect.Method) DefaultKeepAliveStrategy(org.asynchttpclient.channel.DefaultKeepAliveStrategy) HttpRequest(io.netty.handler.codec.http.HttpRequest) BeforeMethod(org.testng.annotations.BeforeMethod) Set(java.util.Set) KeyStore(java.security.KeyStore) Assert.assertNotNull(org.testng.Assert.assertNotNull) Collectors(java.util.stream.Collectors) AuthenticationDataSource(org.apache.pulsar.broker.authentication.AuthenticationDataSource) Sets(com.google.common.collect.Sets) Matchers.any(org.mockito.Matchers.any) ServiceUnitId(org.apache.pulsar.common.naming.ServiceUnitId) Certificate(java.security.cert.Certificate) PrivateKey(java.security.PrivateKey) BoundRequestBuilder(org.asynchttpclient.BoundRequestBuilder) ModularLoadManagerWrapper(org.apache.pulsar.broker.loadbalance.impl.ModularLoadManagerWrapper) ServiceConfig(org.apache.pulsar.discovery.service.server.ServiceConfig) Optional(java.util.Optional) HttpResponse(io.netty.handler.codec.http.HttpResponse) PortManager.nextFreePort(org.apache.bookkeeper.test.PortManager.nextFreePort) MoreExecutors(com.google.common.util.concurrent.MoreExecutors) TopicName(org.apache.pulsar.common.naming.TopicName) AsyncHttpClient(org.asynchttpclient.AsyncHttpClient) SecurityUtility(org.apache.pulsar.common.util.SecurityUtility) Assert.assertEquals(org.testng.Assert.assertEquals) AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) ModularLoadManagerImpl(org.apache.pulsar.broker.loadbalance.impl.ModularLoadManagerImpl) HashMap(java.util.HashMap) CompletableFuture(java.util.concurrent.CompletableFuture) ResourceUnit(org.apache.pulsar.broker.loadbalance.ResourceUnit) NamespaceService(org.apache.pulsar.broker.namespace.NamespaceService) PartitionedTopicMetadata(org.apache.pulsar.common.partition.PartitionedTopicMetadata) Mockito.spy(org.mockito.Mockito.spy) AtomicReference(java.util.concurrent.atomic.AtomicReference) AuthenticationTls(org.apache.pulsar.client.impl.auth.AuthenticationTls) InsecureTrustManagerFactory(io.netty.handler.ssl.util.InsecureTrustManagerFactory) Lists(com.google.common.collect.Lists) ListenableFuture(org.asynchttpclient.ListenableFuture) URLConnection(java.net.URLConnection) SimpleResourceUnit(org.apache.pulsar.broker.loadbalance.impl.SimpleResourceUnit) NamespaceBundle(org.apache.pulsar.common.naming.NamespaceBundle) DefaultAsyncHttpClient(org.asynchttpclient.DefaultAsyncHttpClient) LeaderElectionService(org.apache.pulsar.broker.loadbalance.LeaderElectionService) HttpsURLConnection(javax.net.ssl.HttpsURLConnection) PropertyAdmin(org.apache.pulsar.common.policies.data.PropertyAdmin) Logger(org.slf4j.Logger) AuthenticationProvider(org.apache.pulsar.broker.authentication.AuthenticationProvider) ServiceConfiguration(org.apache.pulsar.broker.ServiceConfiguration) Assert.fail(org.testng.Assert.fail) KeyManagerFactory(javax.net.ssl.KeyManagerFactory) IOException(java.io.IOException) Response(org.asynchttpclient.Response) Field(java.lang.reflect.Field) PulsarService(org.apache.pulsar.broker.PulsarService) KeyManager(javax.net.ssl.KeyManager) ExecutionException(java.util.concurrent.ExecutionException) TimeUnit(java.util.concurrent.TimeUnit) Assert.assertTrue(org.testng.Assert.assertTrue) AsyncCompletionHandler(org.asynchttpclient.AsyncCompletionHandler) InputStream(java.io.InputStream) NamespaceBundle(org.apache.pulsar.common.naming.NamespaceBundle) LoadManager(org.apache.pulsar.broker.loadbalance.LoadManager) URI(java.net.URI) TopicName(org.apache.pulsar.common.naming.TopicName) Field(java.lang.reflect.Field) SimpleResourceUnit(org.apache.pulsar.broker.loadbalance.impl.SimpleResourceUnit) ServiceConfiguration(org.apache.pulsar.broker.ServiceConfiguration) PulsarService(org.apache.pulsar.broker.PulsarService) ServiceUnitId(org.apache.pulsar.common.naming.ServiceUnitId) Test(org.testng.annotations.Test)

Example 17 with Sets

use of org.apache.flink.shaded.guava30.com.google.common.collect.Sets in project incubator-pulsar by apache.

the class BrokerServiceLookupTest method testModularLoadManagerSplitBundle.

/**
 * <pre>
 * When broker-1's Modular-load-manager splits the bundle and update local-policies, broker-2 should get watch of
 * local-policies and update bundleCache so, new lookup can be redirected properly.
 *
 * (1) Start broker-1 and broker-2
 * (2) Make sure broker-2 always assign bundle to broker1
 * (3) Broker-2 receives topic-1 request, creates local-policies and sets the watch
 * (4) Broker-1 will own topic-1
 * (5) Broker-2 will be a leader and trigger Split the bundle for topic-1
 * (6) Broker-2 should get the watch and update bundle cache
 * (7) Make lookup request again to Broker-2 which should succeed.
 *
 * </pre>
 *
 * @throws Exception
 */
@Test(timeOut = 5000)
public void testModularLoadManagerSplitBundle() throws Exception {
    log.info("-- Starting {} test --", methodName);
    final String loadBalancerName = conf.getLoadManagerClassName();
    try {
        final String namespace = "my-property/use/my-ns";
        // (1) Start broker-1
        ServiceConfiguration conf2 = new ServiceConfiguration();
        conf2.setAdvertisedAddress("localhost");
        conf2.setBrokerServicePort(PortManager.nextFreePort());
        conf2.setBrokerServicePortTls(PortManager.nextFreePort());
        conf2.setWebServicePort(PortManager.nextFreePort());
        conf2.setWebServicePortTls(PortManager.nextFreePort());
        conf2.setAdvertisedAddress("localhost");
        conf2.setClusterName(conf.getClusterName());
        conf2.setLoadManagerClassName(ModularLoadManagerImpl.class.getName());
        conf2.setZookeeperServers("localhost:2181");
        PulsarService pulsar2 = startBroker(conf2);
        // configure broker-1 with ModularLoadlManager
        stopBroker();
        conf.setLoadManagerClassName(ModularLoadManagerImpl.class.getName());
        startBroker();
        pulsar.getLoadManager().get().writeLoadReportOnZookeeper();
        pulsar2.getLoadManager().get().writeLoadReportOnZookeeper();
        LoadManager loadManager1 = spy(pulsar.getLoadManager().get());
        LoadManager loadManager2 = spy(pulsar2.getLoadManager().get());
        Field loadManagerField = NamespaceService.class.getDeclaredField("loadManager");
        loadManagerField.setAccessible(true);
        // (2) Make sure broker-2 always assign bundle to broker1
        // mock: redirect request to leader [2]
        doReturn(true).when(loadManager2).isCentralized();
        loadManagerField.set(pulsar2.getNamespaceService(), new AtomicReference<>(loadManager2));
        // mock: return Broker1 as a Least-loaded broker when leader receies request [3]
        doReturn(true).when(loadManager1).isCentralized();
        SimpleResourceUnit resourceUnit = new SimpleResourceUnit(pulsar.getWebServiceAddress(), null);
        Optional<ResourceUnit> res = Optional.of(resourceUnit);
        doReturn(res).when(loadManager1).getLeastLoaded(any(ServiceUnitId.class));
        loadManagerField.set(pulsar.getNamespaceService(), new AtomicReference<>(loadManager1));
        URI broker2ServiceUrl = new URI("pulsar://localhost:" + conf2.getBrokerServicePort());
        PulsarClient pulsarClient2 = PulsarClient.builder().serviceUrl(broker2ServiceUrl.toString()).build();
        // (3) Broker-2 receives topic-1 request, creates local-policies and sets the watch
        final String topic1 = "persistent://" + namespace + "/topic1";
        Consumer<byte[]> consumer1 = pulsarClient2.newConsumer().topic(topic1).subscriptionName("my-subscriber-name").subscribe();
        Set<String> serviceUnits1 = pulsar.getNamespaceService().getOwnedServiceUnits().stream().map(nb -> nb.toString()).collect(Collectors.toSet());
        // (4) Broker-1 will own topic-1
        final String unsplitBundle = namespace + "/0x00000000_0xffffffff";
        assertTrue(serviceUnits1.contains(unsplitBundle));
        // broker-2 should have this bundle into the cache
        TopicName topicName = TopicName.get(topic1);
        NamespaceBundle bundleInBroker2 = pulsar2.getNamespaceService().getBundle(topicName);
        assertEquals(bundleInBroker2.toString(), unsplitBundle);
        // update broker-1 bundle report to zk
        pulsar.getBrokerService().updateRates();
        pulsar.getLoadManager().get().writeLoadReportOnZookeeper();
        // this will create znode for bundle-data
        pulsar.getLoadManager().get().writeResourceQuotasToZooKeeper();
        pulsar2.getLoadManager().get().writeLoadReportOnZookeeper();
        // (5) Modular-load-manager will split the bundle due to max-topic threshold reached
        Field leaderField = LeaderElectionService.class.getDeclaredField("isLeader");
        Method updateAllMethod = ModularLoadManagerImpl.class.getDeclaredMethod("updateAll");
        updateAllMethod.setAccessible(true);
        leaderField.setAccessible(true);
        AtomicBoolean isLeader = (AtomicBoolean) leaderField.get(pulsar2.getLeaderElectionService());
        isLeader.set(true);
        ModularLoadManagerImpl loadManager = (ModularLoadManagerImpl) ((ModularLoadManagerWrapper) pulsar2.getLoadManager().get()).getLoadManager();
        // broker-2 loadManager is a leader and let it refresh load-report from all the brokers
        updateAllMethod.invoke(loadManager);
        conf2.setLoadBalancerAutoBundleSplitEnabled(true);
        conf2.setLoadBalancerAutoUnloadSplitBundlesEnabled(true);
        conf2.setLoadBalancerNamespaceBundleMaxTopics(0);
        loadManager.checkNamespaceBundleSplit();
        // (6) Broker-2 should get the watch and update bundle cache
        final int retry = 5;
        for (int i = 0; i < retry; i++) {
            if (pulsar2.getNamespaceService().getBundle(topicName).equals(bundleInBroker2) && i != retry - 1) {
                Thread.sleep(200);
            } else {
                break;
            }
        }
        // (7) Make lookup request again to Broker-2 which should succeed.
        final String topic2 = "persistent://" + namespace + "/topic2";
        Consumer<byte[]> consumer2 = pulsarClient.newConsumer().topic(topic2).subscriptionName("my-subscriber-name").subscribe();
        NamespaceBundle bundleInBroker1AfterSplit = pulsar2.getNamespaceService().getBundle(TopicName.get(topic2));
        assertFalse(bundleInBroker1AfterSplit.equals(unsplitBundle));
        consumer1.close();
        consumer2.close();
        pulsarClient2.close();
        pulsar2.close();
    } finally {
        conf.setLoadManagerClassName(loadBalancerName);
    }
}
Also used : HttpURLConnection(java.net.HttpURLConnection) SSLContext(javax.net.ssl.SSLContext) URL(java.net.URL) DiscoveryService(org.apache.pulsar.discovery.service.DiscoveryService) Request(org.asynchttpclient.Request) ObjectMapperFactory(org.apache.pulsar.common.util.ObjectMapperFactory) LoggerFactory(org.slf4j.LoggerFactory) TrustManager(javax.net.ssl.TrustManager) Cleanup(lombok.Cleanup) LoadManager(org.apache.pulsar.broker.loadbalance.LoadManager) Test(org.testng.annotations.Test) ClusterData(org.apache.pulsar.common.policies.data.ClusterData) PortManager(org.apache.bookkeeper.test.PortManager) AfterMethod(org.testng.annotations.AfterMethod) AuthenticationException(javax.naming.AuthenticationException) SecureRandom(java.security.SecureRandom) AsyncHttpClientConfig(org.asynchttpclient.AsyncHttpClientConfig) Map(java.util.Map) DefaultAsyncHttpClientConfig(org.asynchttpclient.DefaultAsyncHttpClientConfig) URI(java.net.URI) Mockito.doReturn(org.mockito.Mockito.doReturn) Assert.assertFalse(org.testng.Assert.assertFalse) Method(java.lang.reflect.Method) DefaultKeepAliveStrategy(org.asynchttpclient.channel.DefaultKeepAliveStrategy) HttpRequest(io.netty.handler.codec.http.HttpRequest) BeforeMethod(org.testng.annotations.BeforeMethod) Set(java.util.Set) KeyStore(java.security.KeyStore) Assert.assertNotNull(org.testng.Assert.assertNotNull) Collectors(java.util.stream.Collectors) AuthenticationDataSource(org.apache.pulsar.broker.authentication.AuthenticationDataSource) Sets(com.google.common.collect.Sets) Matchers.any(org.mockito.Matchers.any) ServiceUnitId(org.apache.pulsar.common.naming.ServiceUnitId) Certificate(java.security.cert.Certificate) PrivateKey(java.security.PrivateKey) BoundRequestBuilder(org.asynchttpclient.BoundRequestBuilder) ModularLoadManagerWrapper(org.apache.pulsar.broker.loadbalance.impl.ModularLoadManagerWrapper) ServiceConfig(org.apache.pulsar.discovery.service.server.ServiceConfig) Optional(java.util.Optional) HttpResponse(io.netty.handler.codec.http.HttpResponse) PortManager.nextFreePort(org.apache.bookkeeper.test.PortManager.nextFreePort) MoreExecutors(com.google.common.util.concurrent.MoreExecutors) TopicName(org.apache.pulsar.common.naming.TopicName) AsyncHttpClient(org.asynchttpclient.AsyncHttpClient) SecurityUtility(org.apache.pulsar.common.util.SecurityUtility) Assert.assertEquals(org.testng.Assert.assertEquals) AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) ModularLoadManagerImpl(org.apache.pulsar.broker.loadbalance.impl.ModularLoadManagerImpl) HashMap(java.util.HashMap) CompletableFuture(java.util.concurrent.CompletableFuture) ResourceUnit(org.apache.pulsar.broker.loadbalance.ResourceUnit) NamespaceService(org.apache.pulsar.broker.namespace.NamespaceService) PartitionedTopicMetadata(org.apache.pulsar.common.partition.PartitionedTopicMetadata) Mockito.spy(org.mockito.Mockito.spy) AtomicReference(java.util.concurrent.atomic.AtomicReference) AuthenticationTls(org.apache.pulsar.client.impl.auth.AuthenticationTls) InsecureTrustManagerFactory(io.netty.handler.ssl.util.InsecureTrustManagerFactory) Lists(com.google.common.collect.Lists) ListenableFuture(org.asynchttpclient.ListenableFuture) URLConnection(java.net.URLConnection) SimpleResourceUnit(org.apache.pulsar.broker.loadbalance.impl.SimpleResourceUnit) NamespaceBundle(org.apache.pulsar.common.naming.NamespaceBundle) DefaultAsyncHttpClient(org.asynchttpclient.DefaultAsyncHttpClient) LeaderElectionService(org.apache.pulsar.broker.loadbalance.LeaderElectionService) HttpsURLConnection(javax.net.ssl.HttpsURLConnection) PropertyAdmin(org.apache.pulsar.common.policies.data.PropertyAdmin) Logger(org.slf4j.Logger) AuthenticationProvider(org.apache.pulsar.broker.authentication.AuthenticationProvider) ServiceConfiguration(org.apache.pulsar.broker.ServiceConfiguration) Assert.fail(org.testng.Assert.fail) KeyManagerFactory(javax.net.ssl.KeyManagerFactory) IOException(java.io.IOException) Response(org.asynchttpclient.Response) Field(java.lang.reflect.Field) PulsarService(org.apache.pulsar.broker.PulsarService) KeyManager(javax.net.ssl.KeyManager) ExecutionException(java.util.concurrent.ExecutionException) TimeUnit(java.util.concurrent.TimeUnit) Assert.assertTrue(org.testng.Assert.assertTrue) AsyncCompletionHandler(org.asynchttpclient.AsyncCompletionHandler) InputStream(java.io.InputStream) NamespaceBundle(org.apache.pulsar.common.naming.NamespaceBundle) LoadManager(org.apache.pulsar.broker.loadbalance.LoadManager) AfterMethod(org.testng.annotations.AfterMethod) Method(java.lang.reflect.Method) BeforeMethod(org.testng.annotations.BeforeMethod) URI(java.net.URI) ModularLoadManagerImpl(org.apache.pulsar.broker.loadbalance.impl.ModularLoadManagerImpl) TopicName(org.apache.pulsar.common.naming.TopicName) ResourceUnit(org.apache.pulsar.broker.loadbalance.ResourceUnit) SimpleResourceUnit(org.apache.pulsar.broker.loadbalance.impl.SimpleResourceUnit) Field(java.lang.reflect.Field) AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) SimpleResourceUnit(org.apache.pulsar.broker.loadbalance.impl.SimpleResourceUnit) ServiceConfiguration(org.apache.pulsar.broker.ServiceConfiguration) PulsarService(org.apache.pulsar.broker.PulsarService) ServiceUnitId(org.apache.pulsar.common.naming.ServiceUnitId) Test(org.testng.annotations.Test)

Example 18 with Sets

use of org.apache.flink.shaded.guava30.com.google.common.collect.Sets in project gerrit by GerritCodeReview.

the class ChangeJson method toChangeInfoImpl.

private ChangeInfo toChangeInfoImpl(ChangeData cd, Optional<PatchSet.Id> limitToPsId, List<PluginDefinedInfo> pluginInfos) throws PatchListNotAvailableException, GpgException, PermissionBackendException, IOException {
    ChangeInfo out = new ChangeInfo();
    CurrentUser user = userProvider.get();
    if (has(CHECK)) {
        out.problems = checkerProvider.get().check(cd.notes(), fix).problems();
        // If any problems were fixed, the ChangeData needs to be reloaded.
        for (ProblemInfo p : out.problems) {
            if (p.status == ProblemInfo.Status.FIXED) {
                cd = changeDataFactory.create(cd.project(), cd.getId());
                break;
            }
        }
    }
    Change in = cd.change();
    out.project = in.getProject().get();
    out.branch = in.getDest().shortName();
    out.topic = in.getTopic();
    if (!cd.attentionSet().isEmpty()) {
        out.removedFromAttentionSet = removalsOnly(cd.attentionSet()).stream().collect(toImmutableMap(a -> a.account().get(), a -> AttentionSetUtil.createAttentionSetInfo(a, accountLoader)));
        out.attentionSet = // This filtering should match GetAttentionSet.
        additionsOnly(cd.attentionSet()).stream().collect(toImmutableMap(a -> a.account().get(), a -> AttentionSetUtil.createAttentionSetInfo(a, accountLoader)));
    }
    out.assignee = in.getAssignee() != null ? accountLoader.get(in.getAssignee()) : null;
    out.hashtags = cd.hashtags();
    out.changeId = in.getKey().get();
    if (in.isNew()) {
        SubmitTypeRecord str = cd.submitTypeRecord();
        if (str.isOk()) {
            out.submitType = str.type;
        }
        if (includeMergeable) {
            out.mergeable = cd.isMergeable();
        }
        if (has(SUBMITTABLE)) {
            out.submittable = submittable(cd);
        }
    }
    if (!has(SKIP_DIFFSTAT)) {
        Optional<ChangedLines> changedLines = cd.changedLines();
        if (changedLines.isPresent()) {
            out.insertions = changedLines.get().insertions;
            out.deletions = changedLines.get().deletions;
        }
    }
    out.isPrivate = in.isPrivate() ? true : null;
    out.workInProgress = in.isWorkInProgress() ? true : null;
    out.hasReviewStarted = in.hasReviewStarted();
    out.subject = in.getSubject();
    out.status = in.getStatus().asChangeStatus();
    out.owner = accountLoader.get(in.getOwner());
    out.setCreated(in.getCreatedOn());
    out.setUpdated(in.getLastUpdatedOn());
    out._number = in.getId().get();
    out.totalCommentCount = cd.totalCommentCount();
    out.unresolvedCommentCount = cd.unresolvedCommentCount();
    if (cd.getRefStates() != null) {
        String metaName = RefNames.changeMetaRef(cd.getId());
        Optional<RefState> metaState = cd.getRefStates().values().stream().filter(r -> r.ref().equals(metaName)).findAny();
        // metaState should always be there, but it doesn't hurt to be extra careful.
        metaState.ifPresent(rs -> out.metaRevId = rs.id().getName());
    }
    if (user.isIdentifiedUser()) {
        Collection<String> stars = cd.stars(user.getAccountId());
        out.starred = stars.contains(StarredChangesUtil.DEFAULT_LABEL) ? true : null;
        if (!stars.isEmpty()) {
            out.stars = stars;
        }
    }
    if (in.isNew() && has(REVIEWED) && user.isIdentifiedUser()) {
        out.reviewed = cd.isReviewedBy(user.getAccountId()) ? true : null;
    }
    out.labels = labelsJson.labelsFor(accountLoader, cd, has(LABELS), has(DETAILED_LABELS));
    out.requirements = requirementsFor(cd);
    out.submitRecords = submitRecordsFor(cd);
    if (has(SUBMIT_REQUIREMENTS)) {
        out.submitRequirements = submitRequirementsFor(cd);
    }
    if (out.labels != null && has(DETAILED_LABELS)) {
        // list permitted labels, since users can't vote on those patch sets.
        if (user.isIdentifiedUser() && (!limitToPsId.isPresent() || limitToPsId.get().equals(in.currentPatchSetId()))) {
            out.permittedLabels = !cd.change().isAbandoned() ? labelsJson.permittedLabels(user.getAccountId(), cd) : ImmutableMap.of();
        }
    }
    if (has(LABELS) || has(DETAILED_LABELS)) {
        out.reviewers = reviewerMap(cd.reviewers(), cd.reviewersByEmail(), false);
        out.pendingReviewers = reviewerMap(cd.pendingReviewers(), cd.pendingReviewersByEmail(), true);
        out.removableReviewers = removableReviewers(cd, out);
    }
    setSubmitter(cd, out);
    if (!pluginInfos.isEmpty()) {
        out.plugins = pluginInfos;
    }
    out.revertOf = cd.change().getRevertOf() != null ? cd.change().getRevertOf().get() : null;
    out.submissionId = cd.change().getSubmissionId();
    out.cherryPickOfChange = cd.change().getCherryPickOf() != null ? cd.change().getCherryPickOf().changeId().get() : null;
    out.cherryPickOfPatchSet = cd.change().getCherryPickOf() != null ? cd.change().getCherryPickOf().get() : null;
    if (has(REVIEWER_UPDATES)) {
        out.reviewerUpdates = reviewerUpdates(cd);
    }
    boolean needMessages = has(MESSAGES);
    boolean needRevisions = has(ALL_REVISIONS) || has(CURRENT_REVISION) || limitToPsId.isPresent();
    Map<PatchSet.Id, PatchSet> src;
    if (needMessages || needRevisions) {
        src = loadPatchSets(cd, limitToPsId);
    } else {
        src = null;
    }
    if (needMessages) {
        out.messages = messages(cd);
    }
    finish(out);
    // it will be passed to ActionVisitors as-is.
    if (needRevisions) {
        out.revisions = revisionJson.getRevisions(accountLoader, cd, src, limitToPsId, out);
        if (out.revisions != null) {
            for (Map.Entry<String, RevisionInfo> entry : out.revisions.entrySet()) {
                if (entry.getValue().isCurrent) {
                    out.currentRevision = entry.getKey();
                    break;
                }
            }
        }
    }
    if (has(CURRENT_ACTIONS) || has(CHANGE_ACTIONS)) {
        actionJson.addChangeActions(out, cd);
    }
    if (has(TRACKING_IDS)) {
        ListMultimap<String, String> set = trackingFooters.extract(cd.commitFooters());
        out.trackingIds = set.entries().stream().map(e -> new TrackingIdInfo(e.getKey(), e.getValue())).collect(toList());
    }
    return out;
}
Also used : AttentionSetUtil.additionsOnly(com.google.gerrit.server.util.AttentionSetUtil.additionsOnly) REVIEWER_UPDATES(com.google.gerrit.extensions.client.ListChangesOption.REVIEWER_UPDATES) LabelInfo(com.google.gerrit.extensions.common.LabelInfo) ListMultimap(com.google.common.collect.ListMultimap) TrackingIdInfo(com.google.gerrit.extensions.common.TrackingIdInfo) PermissionBackend(com.google.gerrit.server.permissions.PermissionBackend) ReviewerSet(com.google.gerrit.server.ReviewerSet) SubmitRequirementResult(com.google.gerrit.entities.SubmitRequirementResult) Config(org.eclipse.jgit.lib.Config) Map(java.util.Map) LABELS(com.google.gerrit.extensions.client.ListChangesOption.LABELS) AttentionSetUtil.removalsOnly(com.google.gerrit.server.util.AttentionSetUtil.removalsOnly) ApprovalInfo(com.google.gerrit.extensions.common.ApprovalInfo) GerritServerConfig(com.google.gerrit.server.config.GerritServerConfig) Timer0(com.google.gerrit.metrics.Timer0) Set(java.util.Set) ReviewerStatusUpdate(com.google.gerrit.server.ReviewerStatusUpdate) SubmitRecord(com.google.gerrit.entities.SubmitRecord) SUBMITTABLE(com.google.gerrit.extensions.client.ListChangesOption.SUBMITTABLE) SubmitTypeRecord(com.google.gerrit.entities.SubmitTypeRecord) ImmutableMap.toImmutableMap(com.google.common.collect.ImmutableMap.toImmutableMap) MESSAGES(com.google.gerrit.extensions.client.ListChangesOption.MESSAGES) ImmutableListMultimap(com.google.common.collect.ImmutableListMultimap) DETAILED_ACCOUNTS(com.google.gerrit.extensions.client.ListChangesOption.DETAILED_ACCOUNTS) MetricMaker(com.google.gerrit.metrics.MetricMaker) FluentLogger(com.google.common.flogger.FluentLogger) Joiner(com.google.common.base.Joiner) ChangeMessagesUtil(com.google.gerrit.server.ChangeMessagesUtil) Singleton(com.google.inject.Singleton) PermissionBackendException(com.google.gerrit.server.permissions.PermissionBackendException) ArrayList(java.util.ArrayList) CURRENT_COMMIT(com.google.gerrit.extensions.client.ListChangesOption.CURRENT_COMMIT) ChangeMessage(com.google.gerrit.entities.ChangeMessage) Lists(com.google.common.collect.Lists) Description(com.google.gerrit.metrics.Description) PatchSet(com.google.gerrit.entities.PatchSet) Address(com.google.gerrit.entities.Address) RefState(com.google.gerrit.index.RefState) CURRENT_ACTIONS(com.google.gerrit.extensions.client.ListChangesOption.CURRENT_ACTIONS) StorageException(com.google.gerrit.exceptions.StorageException) Units(com.google.gerrit.metrics.Description.Units) MoreObjects(com.google.common.base.MoreObjects) Throwables(com.google.common.base.Throwables) ChangeNotes(com.google.gerrit.server.notedb.ChangeNotes) IOException(java.io.IOException) ReviewerUpdateInfo(com.google.gerrit.extensions.common.ReviewerUpdateInfo) SubmitRuleOptions(com.google.gerrit.server.project.SubmitRuleOptions) LegacySubmitRequirementInfo(com.google.gerrit.extensions.common.LegacySubmitRequirementInfo) Project(com.google.gerrit.entities.Project) TrackingFooters(com.google.gerrit.server.config.TrackingFooters) ReviewerByEmailSet(com.google.gerrit.server.ReviewerByEmailSet) RequestCancelledException(com.google.gerrit.server.cancellation.RequestCancelledException) ALL_REVISIONS(com.google.gerrit.extensions.client.ListChangesOption.ALL_REVISIONS) Inject(com.google.inject.Inject) RevisionInfo(com.google.gerrit.extensions.common.RevisionInfo) Assisted(com.google.inject.assistedinject.Assisted) PatchSetApproval(com.google.gerrit.entities.PatchSetApproval) LegacySubmitRequirement(com.google.gerrit.entities.LegacySubmitRequirement) RemoveReviewerControl(com.google.gerrit.server.project.RemoveReviewerControl) AccountInfo(com.google.gerrit.extensions.common.AccountInfo) GpgException(com.google.gerrit.server.GpgException) REVIEWED(com.google.gerrit.extensions.client.ListChangesOption.REVIEWED) RefNames(com.google.gerrit.entities.RefNames) SubmitRequirementResultInfo(com.google.gerrit.extensions.common.SubmitRequirementResultInfo) CHECK(com.google.gerrit.extensions.client.ListChangesOption.CHECK) ChangedLines(com.google.gerrit.server.query.change.ChangeData.ChangedLines) ImmutableSet(com.google.common.collect.ImmutableSet) ImmutableMap(com.google.common.collect.ImmutableMap) Collection(java.util.Collection) DETAILED_LABELS(com.google.gerrit.extensions.client.ListChangesOption.DETAILED_LABELS) Account(com.google.gerrit.entities.Account) Collectors(java.util.stream.Collectors) Sets(com.google.common.collect.Sets) ChangeData(com.google.gerrit.server.query.change.ChangeData) List(java.util.List) Nullable(com.google.gerrit.common.Nullable) Url(com.google.gerrit.extensions.restapi.Url) Optional(java.util.Optional) AttentionSetUtil(com.google.gerrit.server.util.AttentionSetUtil) PatchListNotAvailableException(com.google.gerrit.server.patch.PatchListNotAvailableException) AccountLoader(com.google.gerrit.server.account.AccountLoader) FixInput(com.google.gerrit.extensions.api.changes.FixInput) ChangePermission(com.google.gerrit.server.permissions.ChangePermission) ReviewerState(com.google.gerrit.extensions.client.ReviewerState) HashMap(java.util.HashMap) HashSet(java.util.HashSet) ImmutableList(com.google.common.collect.ImmutableList) CURRENT_REVISION(com.google.gerrit.extensions.client.ListChangesOption.CURRENT_REVISION) ChangeInfo(com.google.gerrit.extensions.common.ChangeInfo) SubmitRecordInfo(com.google.gerrit.extensions.common.SubmitRecordInfo) SKIP_DIFFSTAT(com.google.gerrit.extensions.client.ListChangesOption.SKIP_DIFFSTAT) ChangeMessagesUtil.createChangeMessageInfo(com.google.gerrit.server.ChangeMessagesUtil.createChangeMessageInfo) Change(com.google.gerrit.entities.Change) ListChangesOption(com.google.gerrit.extensions.client.ListChangesOption) PluginDefinedInfo(com.google.gerrit.extensions.common.PluginDefinedInfo) TRACKING_IDS(com.google.gerrit.extensions.client.ListChangesOption.TRACKING_IDS) ProblemInfo(com.google.gerrit.extensions.common.ProblemInfo) CurrentUser(com.google.gerrit.server.CurrentUser) QueryResult(com.google.gerrit.index.query.QueryResult) Status(com.google.gerrit.entities.SubmitRecord.Status) ReviewerStateInternal(com.google.gerrit.server.notedb.ReviewerStateInternal) AccountInfoComparator(com.google.gerrit.server.account.AccountInfoComparator) ChangeMessageInfo(com.google.gerrit.extensions.common.ChangeMessageInfo) CHANGE_ACTIONS(com.google.gerrit.extensions.client.ListChangesOption.CHANGE_ACTIONS) Maps(com.google.common.collect.Maps) ObjectId(org.eclipse.jgit.lib.ObjectId) ChangeField(com.google.gerrit.server.index.change.ChangeField) Collectors.toList(java.util.stream.Collectors.toList) Provider(com.google.inject.Provider) SUBMIT_REQUIREMENTS(com.google.gerrit.extensions.client.ListChangesOption.SUBMIT_REQUIREMENTS) COMMIT_FOOTERS(com.google.gerrit.extensions.client.ListChangesOption.COMMIT_FOOTERS) ALL_COMMITS(com.google.gerrit.extensions.client.ListChangesOption.ALL_COMMITS) Collections(java.util.Collections) StarredChangesUtil(com.google.gerrit.server.StarredChangesUtil) ChangeInfo(com.google.gerrit.extensions.common.ChangeInfo) CurrentUser(com.google.gerrit.server.CurrentUser) ProblemInfo(com.google.gerrit.extensions.common.ProblemInfo) PatchSet(com.google.gerrit.entities.PatchSet) Change(com.google.gerrit.entities.Change) SubmitTypeRecord(com.google.gerrit.entities.SubmitTypeRecord) RevisionInfo(com.google.gerrit.extensions.common.RevisionInfo) RefState(com.google.gerrit.index.RefState) ObjectId(org.eclipse.jgit.lib.ObjectId) TrackingIdInfo(com.google.gerrit.extensions.common.TrackingIdInfo) Map(java.util.Map) ImmutableMap.toImmutableMap(com.google.common.collect.ImmutableMap.toImmutableMap) ImmutableMap(com.google.common.collect.ImmutableMap) HashMap(java.util.HashMap) ChangedLines(com.google.gerrit.server.query.change.ChangeData.ChangedLines)

Example 19 with Sets

use of org.apache.flink.shaded.guava30.com.google.common.collect.Sets in project gerrit by GerritCodeReview.

the class ReceiveCommits method autoCloseChanges.

private void autoCloseChanges(ReceiveCommand cmd, Task progress) {
    try (TraceTimer traceTimer = newTimer("autoCloseChanges")) {
        logger.atFine().log("Starting auto-closing of changes");
        String refName = cmd.getRefName();
        Set<Change.Id> ids = new HashSet<>();
        // handleRegularCommands
        try {
            retryHelper.changeUpdate("autoCloseChanges", updateFactory -> {
                try (BatchUpdate bu = updateFactory.create(projectState.getNameKey(), user, TimeUtil.now());
                    ObjectInserter ins = repo.newObjectInserter();
                    ObjectReader reader = ins.newReader();
                    RevWalk rw = new RevWalk(reader)) {
                    if (ObjectId.zeroId().equals(cmd.getOldId())) {
                        // potentially expensive computation that loop over all commits.
                        return null;
                    }
                    bu.setRepository(repo, rw, ins);
                    // TODO(dborowitz): Teach BatchUpdate to ignore missing changes.
                    RevCommit newTip = rw.parseCommit(cmd.getNewId());
                    BranchNameKey branch = BranchNameKey.create(project.getNameKey(), refName);
                    rw.reset();
                    rw.sort(RevSort.REVERSE);
                    rw.markStart(newTip);
                    rw.markUninteresting(rw.parseCommit(cmd.getOldId()));
                    Map<Change.Key, ChangeNotes> byKey = null;
                    List<ReplaceRequest> replaceAndClose = new ArrayList<>();
                    int existingPatchSets = 0;
                    int newPatchSets = 0;
                    SubmissionId submissionId = null;
                    COMMIT: for (RevCommit c; (c = rw.next()) != null; ) {
                        rw.parseBody(c);
                        // refs pointing to this commit.
                        for (PatchSet.Id psId : receivePackRefCache.patchSetIdsFromObjectId(c.copy())) {
                            Optional<ChangeNotes> notes = getChangeNotes(psId.changeId());
                            if (notes.isPresent() && notes.get().getChange().getDest().equals(branch)) {
                                if (submissionId == null) {
                                    submissionId = new SubmissionId(notes.get().getChange());
                                }
                                existingPatchSets++;
                                bu.addOp(notes.get().getChangeId(), setPrivateOpFactory.create(false, null));
                                bu.addOp(psId.changeId(), mergedByPushOpFactory.create(requestScopePropagator, psId, submissionId, refName, newTip.getId().getName()));
                                continue COMMIT;
                            }
                        }
                        for (String changeId : ChangeUtil.getChangeIdsFromFooter(c, urlFormatter.get())) {
                            if (byKey == null) {
                                byKey = retryHelper.changeIndexQuery("queryOpenChangesByKeyByBranch", q -> openChangesByKeyByBranch(q, branch)).call();
                            }
                            ChangeNotes onto = byKey.get(Change.key(changeId.trim()));
                            if (onto != null) {
                                newPatchSets++;
                                // Hold onto this until we're done with the walk, as the call to
                                // req.validate below calls isMergedInto which resets the walk.
                                ReplaceRequest req = new ReplaceRequest(onto.getChangeId(), c, cmd, false);
                                req.notes = onto;
                                replaceAndClose.add(req);
                                continue COMMIT;
                            }
                        }
                    }
                    for (ReplaceRequest req : replaceAndClose) {
                        Change.Id id = req.notes.getChangeId();
                        if (!req.validateNewPatchSetForAutoClose()) {
                            logger.atFine().log("Not closing %s because validation failed", id);
                            continue;
                        }
                        if (submissionId == null) {
                            submissionId = new SubmissionId(req.notes.getChange());
                        }
                        req.addOps(bu, null);
                        bu.addOp(id, setPrivateOpFactory.create(false, null));
                        bu.addOp(id, mergedByPushOpFactory.create(requestScopePropagator, req.psId, submissionId, refName, newTip.getId().getName()).setPatchSetProvider(req.replaceOp::getPatchSet));
                        bu.addOp(id, new ChangeProgressOp(progress));
                        ids.add(id);
                    }
                    logger.atFine().log("Auto-closing %d changes with existing patch sets and %d with new patch" + " sets", existingPatchSets, newPatchSets);
                    bu.execute();
                } catch (IOException | StorageException | PermissionBackendException e) {
                    throw new StorageException("Failed to auto-close changes", e);
                }
                // If we are here, we didn't throw UpdateException. Record the result.
                // The ordering is indeterminate due to the HashSet; unfortunately, Change.Id
                // doesn't
                // fit into TreeSet.
                ids.stream().forEach(id -> result.addChange(ReceiveCommitsResult.ChangeStatus.AUTOCLOSED, id));
                return null;
            }).defaultTimeoutMultiplier(5).call();
        } catch (RestApiException e) {
            logger.atSevere().withCause(e).log("Can't insert patchset");
        } catch (UpdateException e) {
            logger.atSevere().withCause(e).log("Failed to auto-close changes");
        } finally {
            logger.atFine().log("Done auto-closing changes");
        }
    }
}
Also used : NotifyInfo(com.google.gerrit.extensions.api.changes.NotifyInfo) DynamicItem(com.google.gerrit.extensions.registration.DynamicItem) MultimapBuilder(com.google.common.collect.MultimapBuilder) ChangeReportFormatter(com.google.gerrit.server.git.ChangeReportFormatter) DeadlineChecker(com.google.gerrit.server.DeadlineChecker) ReceiveCommand(org.eclipse.jgit.transport.ReceiveCommand) RevObject(org.eclipse.jgit.revwalk.RevObject) BadRequestException(com.google.gerrit.extensions.restapi.BadRequestException) HashtagsInput(com.google.gerrit.extensions.api.changes.HashtagsInput) RevWalk(org.eclipse.jgit.revwalk.RevWalk) Config(org.eclipse.jgit.lib.Config) Future(java.util.concurrent.Future) FooterLine(org.eclipse.jgit.revwalk.FooterLine) Map(java.util.Map) UrlFormatter(com.google.gerrit.server.config.UrlFormatter) Metadata(com.google.gerrit.server.logging.Metadata) MailRecipients(com.google.gerrit.server.mail.MailUtil.MailRecipients) RevSort(org.eclipse.jgit.revwalk.RevSort) Constants(org.eclipse.jgit.lib.Constants) PublishCommentsOp(com.google.gerrit.server.PublishCommentsOp) Collectors.joining(java.util.stream.Collectors.joining) RequestListener(com.google.gerrit.server.RequestListener) PersonIdent(org.eclipse.jgit.lib.PersonIdent) TagCache(com.google.gerrit.server.git.TagCache) Stream(java.util.stream.Stream) HashtagsUtil.cleanupHashtag(com.google.gerrit.server.change.HashtagsUtil.cleanupHashtag) BooleanProjectConfig(com.google.gerrit.entities.BooleanProjectConfig) Counter3(com.google.gerrit.metrics.Counter3) PluginSetContext(com.google.gerrit.server.plugincontext.PluginSetContext) ProjectConfigEntryType(com.google.gerrit.extensions.api.projects.ProjectConfigEntryType) Counter0(com.google.gerrit.metrics.Counter0) MetricMaker(com.google.gerrit.metrics.MetricMaker) PatchSetInfo(com.google.gerrit.entities.PatchSetInfo) FluentLogger(com.google.common.flogger.FluentLogger) Joiner(com.google.common.base.Joiner) ValidationError(com.google.gerrit.server.git.ValidationError) SAME_CHANGE_ID_IN_MULTIPLE_CHANGES(com.google.gerrit.server.git.receive.ReceiveConstants.SAME_CHANGE_ID_IN_MULTIPLE_CHANGES) RevCommit(org.eclipse.jgit.revwalk.RevCommit) UnprocessableEntityException(com.google.gerrit.extensions.restapi.UnprocessableEntityException) CommentsUtil(com.google.gerrit.server.CommentsUtil) RequestScopePropagator(com.google.gerrit.server.util.RequestScopePropagator) PerformanceLogger(com.google.gerrit.server.logging.PerformanceLogger) LinkedHashMap(java.util.LinkedHashMap) Strings(com.google.common.base.Strings) Lists(com.google.common.collect.Lists) SubmissionExecutor(com.google.gerrit.server.update.SubmissionExecutor) Description(com.google.gerrit.metrics.Description) ImmutableSet.toImmutableSet(com.google.common.collect.ImmutableSet.toImmutableSet) StreamSupport(java.util.stream.StreamSupport) MagicBranch(com.google.gerrit.server.util.MagicBranch) ProjectCache.illegalState(com.google.gerrit.server.project.ProjectCache.illegalState) NotifyResolver(com.google.gerrit.server.change.NotifyResolver) ObjectIds.abbreviateName(com.google.gerrit.git.ObjectIds.abbreviateName) Throwables(com.google.common.base.Throwables) IOException(java.io.IOException) ExecutionException(java.util.concurrent.ExecutionException) ChangeEdit(com.google.gerrit.server.edit.ChangeEdit) IdentifiedUser(com.google.gerrit.server.IdentifiedUser) Project(com.google.gerrit.entities.Project) DynamicSet(com.google.gerrit.extensions.registration.DynamicSet) NOT_ATTEMPTED(org.eclipse.jgit.transport.ReceiveCommand.Result.NOT_ATTEMPTED) LabelVote(com.google.gerrit.server.util.LabelVote) TimeUtil(com.google.gerrit.server.util.time.TimeUtil) CommentValidator(com.google.gerrit.extensions.validators.CommentValidator) ONLY_USERS_WITH_TOGGLE_WIP_STATE_PERM_CAN_MODIFY_WIP(com.google.gerrit.server.git.receive.ReceiveConstants.ONLY_USERS_WITH_TOGGLE_WIP_STATE_PERM_CAN_MODIFY_WIP) RequestCancelledException(com.google.gerrit.server.cancellation.RequestCancelledException) RequestId(com.google.gerrit.server.logging.RequestId) REJECTED_MISSING_OBJECT(org.eclipse.jgit.transport.ReceiveCommand.Result.REJECTED_MISSING_OBJECT) CommentSizeValidator(com.google.gerrit.server.git.validators.CommentSizeValidator) RefPermission(com.google.gerrit.server.permissions.RefPermission) PUSH_OPTION_SKIP_VALIDATION(com.google.gerrit.server.git.receive.ReceiveConstants.PUSH_OPTION_SKIP_VALIDATION) URLDecoder(java.net.URLDecoder) ValidationMessage(com.google.gerrit.server.git.validators.ValidationMessage) Inject(com.google.inject.Inject) MissingObjectException(org.eclipse.jgit.errors.MissingObjectException) RepoOnlyOp(com.google.gerrit.server.update.RepoOnlyOp) PatchSetInfoFactory(com.google.gerrit.server.patch.PatchSetInfoFactory) UpdateException(com.google.gerrit.server.update.UpdateException) Assisted(com.google.inject.assistedinject.Assisted) ImmutableListMultimap.toImmutableListMultimap(com.google.common.collect.ImmutableListMultimap.toImmutableListMultimap) LabelType(com.google.gerrit.entities.LabelType) AuthException(com.google.gerrit.extensions.restapi.AuthException) AutoMerger(com.google.gerrit.server.patch.AutoMerger) PerformanceLogContext(com.google.gerrit.server.logging.PerformanceLogContext) PluginConfig(com.google.gerrit.server.config.PluginConfig) NoteMap(org.eclipse.jgit.notes.NoteMap) ImmutableSetMultimap(com.google.common.collect.ImmutableSetMultimap) CommentCountValidator(com.google.gerrit.server.git.validators.CommentCountValidator) BiMap(com.google.common.collect.BiMap) ImmutableSet(com.google.common.collect.ImmutableSet) SortedSetMultimap(com.google.common.collect.SortedSetMultimap) Collection(java.util.Collection) OK(org.eclipse.jgit.transport.ReceiveCommand.Result.OK) PermissionDeniedException(com.google.gerrit.server.permissions.PermissionDeniedException) Collectors(java.util.stream.Collectors) ApprovalsUtil(com.google.gerrit.server.approval.ApprovalsUtil) Objects(java.util.Objects) CmdLineException(org.kohsuke.args4j.CmdLineException) SetPrivateOp(com.google.gerrit.server.change.SetPrivateOp) ChangeData(com.google.gerrit.server.query.change.ChangeData) Nullable(com.google.gerrit.common.Nullable) AllProjectsName(com.google.gerrit.server.config.AllProjectsName) Ref(org.eclipse.jgit.lib.Ref) InternalChangeQuery(com.google.gerrit.server.query.change.InternalChangeQuery) Providers(com.google.inject.util.Providers) Queue(java.util.Queue) RefNames.isConfigRef(com.google.gerrit.entities.RefNames.isConfigRef) RequestStateContext(com.google.gerrit.server.cancellation.RequestStateContext) CommentValidationContext(com.google.gerrit.extensions.validators.CommentValidationContext) IncorrectObjectTypeException(org.eclipse.jgit.errors.IncorrectObjectTypeException) GeneralPreferencesInfo(com.google.gerrit.extensions.client.GeneralPreferencesInfo) RepoContext(com.google.gerrit.server.update.RepoContext) MergedByPushOp(com.google.gerrit.server.git.MergedByPushOp) HashSet(java.util.HashSet) ImmutableList(com.google.common.collect.ImmutableList) REFS_CHANGES(com.google.gerrit.entities.RefNames.REFS_CHANGES) Field(com.google.gerrit.metrics.Field) UsedAt(com.google.gerrit.common.UsedAt) Change(com.google.gerrit.entities.Change) ChangeUtil(com.google.gerrit.server.ChangeUtil) ChangeContext(com.google.gerrit.server.update.ChangeContext) SetTopicOp(com.google.gerrit.server.change.SetTopicOp) SetHashtagsOp(com.google.gerrit.server.change.SetHashtagsOp) UTF_8(java.nio.charset.StandardCharsets.UTF_8) ProjectState(com.google.gerrit.server.project.ProjectState) Collectors.toList(java.util.stream.Collectors.toList) HashBiMap(com.google.common.collect.HashBiMap) Provider(com.google.inject.Provider) ReceivePack(org.eclipse.jgit.transport.ReceivePack) SuperprojectUpdateOnSubmission(com.google.gerrit.server.update.SuperprojectUpdateOnSubmission) Arrays(java.util.Arrays) ProjectConfig(com.google.gerrit.server.project.ProjectConfig) ListMultimap(com.google.common.collect.ListMultimap) GroupCollector(com.google.gerrit.server.git.GroupCollector) ProjectCache(com.google.gerrit.server.project.ProjectCache) PermissionBackend(com.google.gerrit.server.permissions.PermissionBackend) InvalidDeadlineException(com.google.gerrit.server.InvalidDeadlineException) NoSuchChangeException(com.google.gerrit.server.project.NoSuchChangeException) RetryHelper(com.google.gerrit.server.update.RetryHelper) GerritServerConfig(com.google.gerrit.server.config.GerritServerConfig) TraceContext(com.google.gerrit.server.logging.TraceContext) ImmutableList.toImmutableList(com.google.common.collect.ImmutableList.toImmutableList) Set(java.util.Set) BranchNameKey(com.google.gerrit.entities.BranchNameKey) NotifyHandling(com.google.gerrit.extensions.api.changes.NotifyHandling) ProjectPermission(com.google.gerrit.server.permissions.ProjectPermission) NEW_PATCHSET_PATTERN(com.google.gerrit.server.git.validators.CommitValidators.NEW_PATCHSET_PATTERN) ImmutableListMultimap(com.google.common.collect.ImmutableListMultimap) LazyArgs.lazy(com.google.common.flogger.LazyArgs.lazy) Singleton(com.google.inject.Singleton) Iterables(com.google.common.collect.Iterables) CommentType(com.google.gerrit.extensions.validators.CommentForValidation.CommentType) PermissionBackendException(com.google.gerrit.server.permissions.PermissionBackendException) RefOperationValidationException(com.google.gerrit.server.git.validators.RefOperationValidationException) ConfigInvalidException(org.eclipse.jgit.errors.ConfigInvalidException) CommentForValidation(com.google.gerrit.extensions.validators.CommentForValidation) TraceTimer(com.google.gerrit.server.logging.TraceContext.TraceTimer) CancellationMetrics(com.google.gerrit.server.CancellationMetrics) SubmissionListener(com.google.gerrit.server.update.SubmissionListener) TreeSet(java.util.TreeSet) ArrayList(java.util.ArrayList) ChangeEditUtil(com.google.gerrit.server.edit.ChangeEditUtil) PatchSet(com.google.gerrit.entities.PatchSet) RestApiException(com.google.gerrit.extensions.restapi.RestApiException) Extension(com.google.gerrit.extensions.registration.Extension) LinkedHashSet(java.util.LinkedHashSet) UNKNOWN(com.google.gerrit.server.git.MultiProgressMonitor.UNKNOWN) CommitValidationMessage(com.google.gerrit.server.git.validators.CommitValidationMessage) Sequences(com.google.gerrit.server.notedb.Sequences) CreateRefControl(com.google.gerrit.server.project.CreateRefControl) RevFilter(org.eclipse.jgit.revwalk.filter.RevFilter) AttentionSetUnchangedOp(com.google.gerrit.server.change.AttentionSetUnchangedOp) StorageException(com.google.gerrit.exceptions.StorageException) StringWriter(java.io.StringWriter) CommentValidationFailure(com.google.gerrit.extensions.validators.CommentValidationFailure) CmdLineParser(com.google.gerrit.util.cli.CmdLineParser) NoSuchProjectException(com.google.gerrit.server.project.NoSuchProjectException) ChangeNotes(com.google.gerrit.server.notedb.ChangeNotes) R_HEADS(org.eclipse.jgit.lib.Constants.R_HEADS) RefOperationValidators(com.google.gerrit.server.git.validators.RefOperationValidators) DynamicMap(com.google.gerrit.extensions.registration.DynamicMap) ObjectReader(org.eclipse.jgit.lib.ObjectReader) Repository(org.eclipse.jgit.lib.Repository) REJECTED_OTHER_REASON(org.eclipse.jgit.transport.ReceiveCommand.Result.REJECTED_OTHER_REASON) MailUtil.getRecipientsFromFooters(com.google.gerrit.server.mail.MailUtil.getRecipientsFromFooters) ObjectInserter(org.eclipse.jgit.lib.ObjectInserter) HumanComment(com.google.gerrit.entities.HumanComment) SubmissionId(com.google.gerrit.entities.SubmissionId) RefNames.isRefsUsersSelf(com.google.gerrit.entities.RefNames.isRefsUsersSelf) LabelTypes(com.google.gerrit.entities.LabelTypes) ChangeIndexer(com.google.gerrit.server.index.change.ChangeIndexer) BatchUpdate(com.google.gerrit.server.update.BatchUpdate) SubmitInput(com.google.gerrit.extensions.api.changes.SubmitInput) RefNames(com.google.gerrit.entities.RefNames) COMMAND_REJECTION_MESSAGE_FOOTER(com.google.gerrit.server.git.receive.ReceiveConstants.COMMAND_REJECTION_MESSAGE_FOOTER) Splitter(com.google.common.base.Splitter) ReceivePackInitializer(com.google.gerrit.server.git.ReceivePackInitializer) LinkedListMultimap(com.google.common.collect.LinkedListMultimap) GlobalPermission(com.google.gerrit.server.permissions.GlobalPermission) Task(com.google.gerrit.server.git.MultiProgressMonitor.Task) ImmutableMap(com.google.common.collect.ImmutableMap) Account(com.google.gerrit.entities.Account) RequestInfo(com.google.gerrit.server.RequestInfo) ProjectConfigEntry(com.google.gerrit.server.config.ProjectConfigEntry) Option(org.kohsuke.args4j.Option) Streams(com.google.common.collect.Streams) Sets(com.google.common.collect.Sets) Preconditions.checkState(com.google.common.base.Preconditions.checkState) List(java.util.List) Optional(java.util.Optional) MoreObjects.firstNonNull(com.google.common.base.MoreObjects.firstNonNull) BatchUpdateOp(com.google.gerrit.server.update.BatchUpdateOp) UnsupportedEncodingException(java.io.UnsupportedEncodingException) ConcurrentLinkedQueue(java.util.concurrent.ConcurrentLinkedQueue) BanCommit(com.google.gerrit.server.git.BanCommit) CommentSource(com.google.gerrit.extensions.validators.CommentForValidation.CommentSource) PublishCommentUtil(com.google.gerrit.server.PublishCommentUtil) MultiProgressMonitor(com.google.gerrit.server.git.MultiProgressMonitor) MergeOpRepoManager(com.google.gerrit.server.submit.MergeOpRepoManager) ChangePermission(com.google.gerrit.server.permissions.ChangePermission) CreateGroupPermissionSyncer(com.google.gerrit.server.CreateGroupPermissionSyncer) HashMap(java.util.HashMap) ReplyAttentionSetUpdates(com.google.gerrit.server.restapi.change.ReplyAttentionSetUpdates) MergeOp(com.google.gerrit.server.submit.MergeOp) PostUpdateContext(com.google.gerrit.server.update.PostUpdateContext) Objects.requireNonNull(java.util.Objects.requireNonNull) ChangeInserter(com.google.gerrit.server.change.ChangeInserter) AccountResolver(com.google.gerrit.server.account.AccountResolver) Iterator(java.util.Iterator) Maps(com.google.common.collect.Maps) ObjectId(org.eclipse.jgit.lib.ObjectId) RecipientType(com.google.gerrit.extensions.api.changes.RecipientType) ResourceConflictException(com.google.gerrit.extensions.restapi.ResourceConflictException) PatchSetUtil(com.google.gerrit.server.PatchSetUtil) Collections(java.util.Collections) ArrayList(java.util.ArrayList) ChangeNotes(com.google.gerrit.server.notedb.ChangeNotes) BatchUpdate(com.google.gerrit.server.update.BatchUpdate) ObjectInserter(org.eclipse.jgit.lib.ObjectInserter) BranchNameKey(com.google.gerrit.entities.BranchNameKey) ObjectReader(org.eclipse.jgit.lib.ObjectReader) UpdateException(com.google.gerrit.server.update.UpdateException) HashSet(java.util.HashSet) LinkedHashSet(java.util.LinkedHashSet) RevCommit(org.eclipse.jgit.revwalk.RevCommit) Optional(java.util.Optional) PermissionBackendException(com.google.gerrit.server.permissions.PermissionBackendException) Change(com.google.gerrit.entities.Change) IOException(java.io.IOException) RevWalk(org.eclipse.jgit.revwalk.RevWalk) TraceTimer(com.google.gerrit.server.logging.TraceContext.TraceTimer) SubmissionId(com.google.gerrit.entities.SubmissionId) RequestId(com.google.gerrit.server.logging.RequestId) SubmissionId(com.google.gerrit.entities.SubmissionId) ObjectId(org.eclipse.jgit.lib.ObjectId) RestApiException(com.google.gerrit.extensions.restapi.RestApiException) StorageException(com.google.gerrit.exceptions.StorageException) BranchNameKey(com.google.gerrit.entities.BranchNameKey)

Aggregations

Sets (com.google.common.collect.Sets)19 Set (java.util.Set)16 Map (java.util.Map)15 List (java.util.List)12 ArrayList (java.util.ArrayList)11 HashMap (java.util.HashMap)11 Collectors (java.util.stream.Collectors)11 HashSet (java.util.HashSet)10 IOException (java.io.IOException)9 Optional (java.util.Optional)9 Collections (java.util.Collections)8 Logger (org.slf4j.Logger)8 LoggerFactory (org.slf4j.LoggerFactory)8 Lists (com.google.common.collect.Lists)6 TimeUnit (java.util.concurrent.TimeUnit)6 ImmutableSet (com.google.common.collect.ImmutableSet)5 InputStream (java.io.InputStream)5 Collection (java.util.Collection)5 ImmutableMap (com.google.common.collect.ImmutableMap)4 Maps (com.google.common.collect.Maps)4