use of com.zimbra.soap.admin.message.AdminDestroyWaitSetRequest in project zm-mailbox by Zimbra.
the class ImapServerListener method deleteWaitSet.
private void deleteWaitSet() throws ServiceException {
ZimbraLog.imap.debug("Deleting waitset %s", wsID);
cancelPendingRequest();
if (wsID != null) {
AdminDestroyWaitSetRequest req = new AdminDestroyWaitSetRequest(wsID);
checkAuth();
try {
synchronized (soapProv) {
try {
soapProv.invokeJaxbAsAdminWithRetry(req);
} catch (SoapFaultException ex) {
if (AdminServiceException.NO_SUCH_WAITSET.equalsIgnoreCase(ex.getCode())) {
ZimbraLog.imap.debug("Caught NO_SUCH_WAITSET exception trying to delete a waitset. Waitset may have been deleted by sweeper. Ignoring.");
}
} catch (ServiceException e) {
ZimbraLog.imap.error("Caught unexpected exception trying to delete a waitset.", e);
}
}
} finally {
wsID = null;
unsetWaitSetIdOnMailboxes();
lastSequence.set(0);
}
}
}
use of com.zimbra.soap.admin.message.AdminDestroyWaitSetRequest in project zm-mailbox by Zimbra.
the class TestImapServerListener method testDestroyWaitset.
@Test
public void testDestroyWaitset() throws Exception {
Assume.assumeNotNull(remoteServer);
Assume.assumeNotNull(remoteAccount);
ZMailbox mboxStore = TestUtil.getZMailbox(REMOTE_USER_NAME);
TestUtil.addMessage(mboxStore, "TestImapServerListener - testDestroyWaitset - init message", Integer.toString(Mailbox.ID_FOLDER_INBOX));
ImapServerListener remoteListener = ImapServerListenerPool.getInstance().get(mboxStore);
RemoteImapMailboxStore imapStore = new RemoteImapMailboxStore(mboxStore);
ImapCredentials creds = new ImapCredentials(remoteAccount);
ImapPath path = new ImapPath("INBOX", creds);
byte params = 0;
ImapHandler handler = new MockImapHandler().setCredentials(creds);
ImapFolder i4folder = new ImapFolder(path, params, handler);
MockImapListener session = new MockImapListener(imapStore, i4folder, handler);
remoteListener.addListener(session);
// wait for waitset session to be created
String waitSetId = remoteListener.getWSId();
TestUtil.waitForSessions(1, 1, 6000, waitSetId, remoteServer);
// delete waitset
ZimbraLog.test.debug("Destroying waitset %s", waitSetId);
AdminDestroyWaitSetRequest destroyReq = new AdminDestroyWaitSetRequest(waitSetId);
SoapTransport transport = TestUtil.getAdminSoapTransport(remoteServer);
AdminDestroyWaitSetResponse destroyResp = JaxbUtil.elementToJaxb(transport.invoke(JaxbUtil.jaxbToElement(destroyReq)));
Assert.assertNotNull("AdminDestroyWaitSetResponse should not be null", destroyResp);
Assert.assertNotNull("AdminDestroyWaitSetResponse::waitSetId should not be null", destroyResp.getWaitSetId());
Assert.assertEquals("AdminDestroyWaitSetResponse has wrong waitSetId", waitSetId, destroyResp.getWaitSetId());
// wait for ImapServerListener to create a new WaitSet
int maxWait = 5000;
while (maxWait > 0) {
if (remoteListener.getWSId() != null && !waitSetId.equalsIgnoreCase(remoteListener.getWSId())) {
break;
} else {
maxWait -= 500;
Thread.sleep(500);
}
}
Assert.assertFalse("ImapServerListener should have created a new waitset", waitSetId.equalsIgnoreCase(remoteListener.getWSId()));
// send a message
session.doneSignal = new CountDownLatch(1);
String subject = "TestImapServerListener - testDestroyWaitset - trigger message";
TestUtil.addMessageLmtp(subject, TestUtil.getAddress(REMOTE_USER_NAME), TestUtil.getAddress("TestImapServerListener-testDestroyWaitset"));
TestUtil.waitForMessages(mboxStore, String.format("in:inbox is:unread \"%s\"", subject), 1, 1000);
try {
session.doneSignal.await((LC.zimbra_waitset_nodata_sleep_time.intValue() / 1000 + 2), TimeUnit.SECONDS);
} catch (Exception e) {
Assert.fail("Wait interrupted.");
}
assertTrue("Expected session to NOT be triggered", session.wasTriggered());
assertFalse("ImapServerListener should have created a new waitset", remoteListener.getWSId().equalsIgnoreCase(waitSetId));
}
use of com.zimbra.soap.admin.message.AdminDestroyWaitSetRequest in project zm-mailbox by Zimbra.
the class TestWaitSetRequest method testDestroyWaitset.
@Test
public void testDestroyWaitset() throws Exception {
ZimbraLog.test.info("Starting testDestroyWaitset");
String user1Name = "testDestroyWaitset_user1";
acc1 = TestUtil.createAccount(user1Name);
ZMailbox mbox = TestUtil.getZMailbox(user1Name);
Set<String> accountIds = new HashSet<String>();
accountIds.add(mbox.getAccountId());
String adminAuthToken = TestUtil.getAdminSoapTransport().getAuthToken().getValue();
AdminCreateWaitSetResponse resp = createAdminWaitSet(accountIds, adminAuthToken, false);
assertNotNull(resp);
waitSetId = resp.getWaitSetId();
assertNotNull(waitSetId);
QueryWaitSetRequest qwsReq = new QueryWaitSetRequest(waitSetId);
QueryWaitSetResponse qwsResp = (QueryWaitSetResponse) sendReq(qwsReq, adminAuthToken, TestUtil.getAdminSoapUrl());
validateQueryWaitSetResponse(qwsResp, acc1.getId(), null, null, false);
AdminDestroyWaitSetRequest destroyReq = new AdminDestroyWaitSetRequest(waitSetId);
AdminDestroyWaitSetResponse destroyResp = (AdminDestroyWaitSetResponse) sendReq(destroyReq, adminAuthToken, TestUtil.getAdminSoapUrl());
assertNotNull("AdminDestroyWaitSetResponse should not be null", destroyResp);
assertNotNull("AdminDestroyWaitSetResponse::waitSetId should not be null", destroyResp.getWaitSetId());
assertEquals("AdminDestroyWaitSetResponse has wrong waitSetId", waitSetId, destroyResp.getWaitSetId());
qwsReq = new QueryWaitSetRequest(waitSetId);
Element faultResp = sendReqExpectedToFail(qwsReq, adminAuthToken, TestUtil.getAdminSoapUrl(), HttpStatus.SC_INTERNAL_SERVER_ERROR);
assertNotNull("should return Element", faultResp);
try {
TestUtil.getAdminSoapTransport().extractBodyElement(faultResp);
fail("Should thrown SoapFaultException");
} catch (SoapFaultException sfe) {
assertEquals("Expecting admin.NO_SUCH_WAITSET", AdminServiceException.NO_SUCH_WAITSET, sfe.getCode());
} catch (SoapParseException spe) {
fail("Should not be throwing SoapParseException. " + spe.getMessage());
}
waitSetId = null;
}
Aggregations