mirror of https://github.com/apache/druid.git
Handle status failures for streaming supervisors (#15174)
* Cleanup logic * newline * remove whitespace * Fix log message * Add test class * PR changes
This commit is contained in:
parent
a27598a487
commit
3173093415
|
@ -24,6 +24,7 @@ import com.google.common.collect.Iterables;
|
|||
import com.google.inject.Inject;
|
||||
import org.apache.druid.java.util.common.StringUtils;
|
||||
import org.apache.druid.server.initialization.jetty.BadRequestException;
|
||||
import org.apache.druid.server.initialization.jetty.ServiceUnavailableException;
|
||||
import org.apache.druid.server.metrics.DataSourceTaskIdHolder;
|
||||
|
||||
import javax.ws.rs.Path;
|
||||
|
@ -73,6 +74,7 @@ public class ChatHandlerResource
|
|||
return handler.get();
|
||||
}
|
||||
|
||||
throw new BadRequestException(StringUtils.format("Can't find chatHandler for handler[%s]", handlerId));
|
||||
// Return HTTP 503 so SpecificTaskRetryPolicy retries in case the handler is not registered yet or has been registered before shutdown.
|
||||
throw new ServiceUnavailableException(StringUtils.format("Can't find chatHandler for handler[%s]", handlerId));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,56 @@
|
|||
/*
|
||||
* 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.druid.segment.realtime.firehose;
|
||||
|
||||
import com.google.common.base.Optional;
|
||||
import org.apache.druid.server.initialization.jetty.ServiceUnavailableException;
|
||||
import org.apache.druid.server.metrics.DataSourceTaskIdHolder;
|
||||
import org.easymock.EasyMock;
|
||||
import org.easymock.EasyMockRunner;
|
||||
import org.easymock.EasyMockSupport;
|
||||
import org.easymock.Mock;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
@RunWith(EasyMockRunner.class)
|
||||
public class ChatHandlerResourceTest extends EasyMockSupport
|
||||
{
|
||||
|
||||
@Mock
|
||||
ChatHandlerProvider handlers;
|
||||
@Mock
|
||||
DataSourceTaskIdHolder dataSourceTaskIdHolder;
|
||||
ChatHandlerResource chatHandlerResource;
|
||||
|
||||
@Test
|
||||
public void test_noHandlerFound()
|
||||
{
|
||||
String handlerId = "handlerId";
|
||||
EasyMock.expect(dataSourceTaskIdHolder.getTaskId()).andReturn(null);
|
||||
EasyMock.expect(handlers.get(handlerId)).andReturn(Optional.absent());
|
||||
|
||||
replayAll();
|
||||
chatHandlerResource = new ChatHandlerResource(handlers, dataSourceTaskIdHolder);
|
||||
Assert.assertThrows(ServiceUnavailableException.class, () -> chatHandlerResource.doTaskChat(handlerId, null));
|
||||
verifyAll();
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue