wujobqtest2.cpp 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. /*##############################################################################
  2. HPCC SYSTEMS software Copyright (C) 2012 HPCC Systems®.
  3. Licensed under the Apache License, Version 2.0 (the "License");
  4. you may not use this file except in compliance with the License.
  5. You may obtain a copy of the License at
  6. http://www.apache.org/licenses/LICENSE-2.0
  7. Unless required by applicable law or agreed to in writing, software
  8. distributed under the License is distributed on an "AS IS" BASIS,
  9. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  10. See the License for the specific language governing permissions and
  11. limitations under the License.
  12. ############################################################################## */
  13. #include "jlib.hpp"
  14. #include "jfile.hpp"
  15. #include "jprop.hpp"
  16. #include "jsocket.hpp"
  17. #include "wujobq.hpp"
  18. #include "mpbase.hpp"
  19. #include "dllserver.hpp"
  20. #include "daclient.hpp"
  21. #include "dasds.hpp"
  22. #include "workunit.hpp"
  23. bool switchWorkunitQueue(const char *wuid, const char *cluster)
  24. {
  25. class cQswitcher: public CInterface, implements IQueueSwitcher
  26. {
  27. public:
  28. IMPLEMENT_IINTERFACE;
  29. void * getQ(const char * qname, const char * wuid)
  30. {
  31. Owned<IJobQueue> q = createJobQueue(qname);
  32. return q->take(wuid);
  33. }
  34. void putQ(const char * qname, const char * wuid, void * qitem)
  35. {
  36. Owned<IJobQueue> q = createJobQueue(qname);
  37. q->enqueue((IJobQueueItem *)qitem);
  38. }
  39. bool isAuto()
  40. {
  41. return false;
  42. }
  43. } switcher;
  44. Owned<IWorkUnitFactory> factory = getWorkUnitFactory();
  45. Owned<IWorkUnit> wu = factory->updateWorkUnit(wuid);
  46. if (!wu)
  47. return false;
  48. return wu->switchThorQueue(cluster, &switcher);
  49. }