Esempio n. 1
0
  public boolean onTouch(MotionEvent event, boolean flip) {
    int action = event.getAction();

    switch (action & MotionEvent.ACTION_MASK) {
      case MotionEvent.ACTION_UP:
      case MotionEvent.ACTION_CANCEL:
        setKeyStates(0);
        return true;

      case MotionEvent.ACTION_DOWN:
      case MotionEvent.ACTION_POINTER_DOWN:
      case MotionEvent.ACTION_MOVE:
      case MotionEvent.ACTION_OUTSIDE:
        break;
      default:
        return false;
    }

    int states = 0;
    int n = Wrapper.MotionEvent_getPointerCount(event);
    for (int i = 0; i < n; i++) {
      float x = getEventX(event, i, flip);
      float y = getEventY(event, i, flip);
      Control c = findControl(x, y);
      if (c != null) {
        states |= getControlStates(c, x, y, Wrapper.MotionEvent_getSize(event, i));
      }
    }
    setKeyStates(states);
    return true;
  }
  public static void readOneLineFromFile() throws RuntimeException {
    // TODO: read 1 line of the file
    LinkedList<String> stringsOfFile = FileManager.readFromFile();

    // Each line contains, type, question, answer
    if (stringsOfFile == null) {
      System.out.println("Line read from file is null");
      throw new RuntimeException("File doesn't exist");
    }

    System.out.println("This list has " + stringsOfFile.size() + " strings");
    for (int i = 0; i < stringsOfFile.size() - 1; ) {
      Wrapper current = new Wrapper();

      // Put the linked list to the wrapper class consecutively
      current.questionType = stringsOfFile.get(i++);
      current.question = stringsOfFile.get(i++);
      current.answer = stringsOfFile.get(i++);

      // Add this question to the question collection
      questionCollection.add(current);
    }

    // Load the first question
    currentQuestion = questionCollection.get(currentQuestionIndex);

    // Update the question count
    questionCount = questionCollection.size();

    // Parse the line
    System.out.println("Finished parsing file");
  }
 @SuppressWarnings("unchecked")
 private <T> List<T> unmarshal(Unmarshaller unmarshaller, Class<T> clazz, String xmlLocation)
     throws JAXBException {
   StreamSource xml = new StreamSource(xmlLocation);
   Wrapper<T> wrapper = (Wrapper<T>) unmarshaller.unmarshal(xml, Wrapper.class).getValue();
   return wrapper.getItems();
 }
Esempio n. 4
0
 /** Returns the default distribution to use for the specified project. */
 public Distribution getDefaultDistribution(File projectDir) {
   Wrapper wrapper = new Wrapper(projectDir);
   if (wrapper.getDistribution() != null) {
     return getDistribution(wrapper.getDistribution());
   }
   return getDownloadedDistribution(GradleVersion.current().getVersion());
 }
Esempio n. 5
0
  @Override
  public void doFilter(
      ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain)
      throws IOException, ServletException {
    HttpServletRequest req = (HttpServletRequest) servletRequest;
    HttpServletResponse resp = (HttpServletResponse) servletResponse;

    String uri = req.getRequestURI();
    String path = uri.substring(0, uri.lastIndexOf("/") + 1);
    String name = uri.substring(uri.lastIndexOf("/") + 1);

    File testFile = new File("src/main/resources/tests" + path + "test-" + name);
    if (req.getParameter("skiptest") == null && testFile.exists() && testFile.isFile()) {
      Wrapper wrapper = new Wrapper(resp);
      filterChain.doFilter(req, wrapper);
      resp.flushBuffer();

      if (wrapper.isWrapped()) {
        String content = new String(wrapper.toByteArray(), "utf-8");
        String test = IOUtils.toString(testFile.toURI().toURL(), "utf-8");
        content = content.replace("</body>", test + "</body>");
        resp.getOutputStream().print(content);
      }
    } else {
      filterChain.doFilter(req, resp);
    }
  }
  // 주식 시세를 변동시키는 메소드
  public void randomForStock() {

    String code = null;
    Stock stocks[] = wrap.getAllStocks();

    for (int i = 0; i < stocks.length; i++) {
      int current = stocks[i].getCurrent();
      float upndwn = stocks[i].getUpnDwn();
      float upndwnper = stocks[i].getUpnDwnPer();
      int selected = (int) (Math.random() * 10);

      if (selected % 2 == 1) {
        current += selected;
        upndwn += selected;
        upndwnper += selected / 10;
        code = "Stock++";
      } else {
        current -= selected;
        upndwn -= selected;
        upndwnper -= selected / 10;
        code = "Stock--";
      }
      stocks[i].setCurrent(current);
      stocks[i].setUpnDwn(upndwn);
      stocks[i].setUpnDwnPer(upndwnper);
    }

    wrap.setAllStocks(stocks);

    // 주식 시세가 변동되었음을 통보하는 객체를 생성
    notice = new Notice(code);
  }
Esempio n. 7
0
  /**
   * Helper method for parallelizing a given fragment. Dependent fragments are parallelized first
   * before parallelizing the given fragment.
   */
  private void parallelizeFragment(
      Wrapper fragmentWrapper,
      PlanningSet planningSet,
      Collection<DrillbitEndpoint> activeEndpoints)
      throws PhysicalOperatorSetupException {
    // If the fragment is already parallelized, return.
    if (fragmentWrapper.isEndpointsAssignmentDone()) {
      return;
    }

    // First parallelize fragments on which this fragment depends on.
    final List<Wrapper> fragmentDependencies = fragmentWrapper.getFragmentDependencies();
    if (fragmentDependencies != null && fragmentDependencies.size() > 0) {
      for (Wrapper dependency : fragmentDependencies) {
        parallelizeFragment(dependency, planningSet, activeEndpoints);
      }
    }

    // Find stats. Stats include various factors including cost of physical operators,
    // parallelizability of
    // work in physical operator and affinity of physical operator to certain nodes.
    fragmentWrapper.getNode().getRoot().accept(new StatsCollector(planningSet), fragmentWrapper);

    fragmentWrapper
        .getStats()
        .getDistributionAffinity()
        .getFragmentParallelizer()
        .parallelizeFragment(fragmentWrapper, this, activeEndpoints);
  }
Esempio n. 8
0
  public static MethodHandle identity(Wrapper wrap) {
    EnumMap<Wrapper, MethodHandle> cache = CONSTANT_FUNCTIONS[1];
    MethodHandle mh = cache.get(wrap);
    if (mh != null) {
      return mh;
    }
    // slow path
    MethodType type = MethodType.methodType(wrap.primitiveType());
    if (wrap != Wrapper.VOID) type = type.appendParameterTypes(wrap.primitiveType());
    try {
      mh = IMPL_LOOKUP.findStatic(THIS_CLASS, "identity", type);
    } catch (ReflectiveOperationException ex) {
      mh = null;
    }
    if (mh == null && wrap == Wrapper.VOID) {
      mh = EMPTY; // #(){} : #()void
    }
    if (mh != null) {
      cache.put(wrap, mh);
      return mh;
    }

    if (mh != null) {
      cache.put(wrap, mh);
      return mh;
    }
    throw new IllegalArgumentException("cannot find identity for " + wrap);
  }
  // 펀드 시세를 변동시키는 메소드
  public void randomForFund() {

    String code = null;
    Fund funds[] = wrap.getAllFunds();

    for (int i = 0; i < funds.length; i++) {

      int current = funds[i].getCurrent();
      float commision = funds[i].getCommision();
      float daycommision = funds[i].getDayCommision();
      int selected = (int) (Math.random() * 10);

      if (selected % 2 == 1) {
        current += selected;
        commision += selected;
        daycommision += selected;
        code = "Fund++";
      } else {
        current -= selected;
        commision -= selected;
        daycommision -= selected;
        code = "Fund--";
      }

      funds[i].setCurrent(current);
      funds[i].setCommision(commision);
      funds[i].setDayCommision(daycommision);
    }

    wrap.setAllFunds(funds);

    // 펀드 시세가 변동되었음을 통보하는 객체를 생성
    notice = new Notice(code);
  }
  // 외환 시세를 변동시키는 메소드
  public void randomForExchange() {

    String code = null;
    Exchange[] exchanges = wrap.getAllExchanges();

    for (int i = 0; i < exchanges.length; i++) {

      float buy = exchanges[i].getBuy();
      float sell = exchanges[i].getSell();
      float rate = exchanges[i].getRate();
      int selected = (int) (Math.random() * 10);

      if (selected % 2 == 1) {
        buy += selected;
        sell += selected;
        rate += selected / 10;
        code = "Exchange++";
      } else {
        buy -= selected;
        sell -= selected;
        rate -= selected / 10;
        code = "Exchange--";
      }

      exchanges[i].setBuy(buy);
      exchanges[i].setSell(sell);
      exchanges[i].setRate(rate);
    }

    wrap.setAllExchanges(exchanges);

    // 외환 시세가 변동되었음을 통보하는 객체를 생성
    notice = new Notice(code);
  }
Esempio n. 11
0
  private void doCoverage(Element element, Wrapper wrapper) {
    int totalCoveredNodesei = wrapper.getCoveredRequirements(RequirementType.NODE).size();
    int totalCoveredEdgesei = wrapper.getCoveredRequirements(RequirementType.EDGE).size();
    int totalCoveredUsesei = wrapper.getCoveredRequirements(RequirementType.DUA).size();

    int totalCheckedNodesei = wrapper.getRequirements(RequirementType.NODE).size();
    int totalCheckedEdgesei = wrapper.getRequirements(RequirementType.EDGE).size();
    int totalCheckedUsesei = wrapper.getRequirements(RequirementType.DUA).size();

    float allNodesei =
        totalCheckedNodesei > 0 ? (float) totalCoveredNodesei / totalCheckedNodesei : 0.0f;
    float allEdgesei =
        totalCheckedEdgesei > 0 ? (float) totalCoveredEdgesei / totalCheckedEdgesei : 0.0f;
    float allUsesei =
        totalCheckedUsesei > 0 ? (float) totalCoveredUsesei / totalCheckedUsesei : 0.0f;

    doTypeCoverage(element, "All-Nodes-ei", totalCoveredNodesei, allNodesei, totalCheckedNodesei);
    doTypeCoverage(element, "All-Nodes-ed", 0, 0.0f, 0);
    doTypeCoverage(element, "All-Edges-ei", totalCoveredEdgesei, allEdgesei, totalCheckedEdgesei);
    doTypeCoverage(element, "All-Edges-ed", 0, 0.0f, 0);
    doTypeCoverage(element, "All-Uses-ei", totalCoveredUsesei, allUsesei, totalCheckedUsesei);
    doTypeCoverage(element, "All-Uses-ed", 0, 0.0f, 0);
    doTypeCoverage(element, "All-Pot-Uses-ei", 0, 0.0f, 0);
    doTypeCoverage(element, "All-Pot-Uses-ed", 0, 0.0f, 0);
  }
Esempio n. 12
0
 public static Object convertArrayElements(Class<?> arrayType, Object array) {
   Class<?> src = array.getClass().getComponentType();
   Class<?> dst = arrayType.getComponentType();
   if (src == null || dst == null) throw new IllegalArgumentException("not array type");
   Wrapper sw = (src.isPrimitive() ? Wrapper.forPrimitiveType(src) : null);
   Wrapper dw = (dst.isPrimitive() ? Wrapper.forPrimitiveType(dst) : null);
   int length;
   if (sw == null) {
     Object[] a = (Object[]) array;
     length = a.length;
     if (dw == null) return Arrays.copyOf(a, length, arrayType.asSubclass(Object[].class));
     Object res = dw.makeArray(length);
     dw.copyArrayUnboxing(a, 0, res, 0, length);
     return res;
   }
   length = j86.java.lang.reflect.Array.getLength(array);
   Object[] res;
   if (dw == null) {
     res = Arrays.copyOf(NO_ARGS_ARRAY, length, arrayType.asSubclass(Object[].class));
   } else {
     res = new Object[length];
   }
   sw.copyArrayBoxing(array, 0, res, 0, length);
   if (dw == null) return res;
   Object a = dw.makeArray(length);
   dw.copyArrayUnboxing(res, 0, a, 0, length);
   return a;
 }
Esempio n. 13
0
 private void checkExecute() throws IOException {
   context.checking(
       new Expectations() {
         {
           one(wrapperScriptGeneratorMock)
               .generate(
                   targetWrapperJarPath + "/" + Wrapper.WRAPPER_JAR,
                   targetWrapperJarPath + "/" + Wrapper.WRAPPER_PROPERTIES,
                   new File(getProject().getProjectDir(), wrapper.getScriptDestinationPath()));
         }
       });
   wrapper.execute();
   TestFile unjarDir = tmpDir.createDir("unjar");
   expectedTargetWrapperJar.unzipTo(unjarDir);
   unjarDir.file(GradleWrapperMain.class.getName().replace(".", "/") + ".class").assertIsFile();
   Properties properties = GUtil.loadProperties(expectedTargetWrapperProperties);
   assertEquals(properties.getProperty(Wrapper.URL_ROOT_PROPERTY), wrapper.getUrlRoot());
   assertEquals(
       properties.getProperty(Wrapper.DISTRIBUTION_BASE_PROPERTY),
       wrapper.getDistributionBase().toString());
   assertEquals(
       properties.getProperty(Wrapper.DISTRIBUTION_PATH_PROPERTY), wrapper.getDistributionPath());
   assertEquals(
       properties.getProperty(Wrapper.DISTRIBUTION_NAME_PROPERTY), wrapper.getArchiveName());
   assertEquals(
       properties.getProperty(Wrapper.DISTRIBUTION_CLASSIFIER_PROPERTY),
       wrapper.getArchiveClassifier());
   assertEquals(
       properties.getProperty(Wrapper.DISTRIBUTION_VERSION_PROPERTY), wrapper.getGradleVersion());
   assertEquals(
       properties.getProperty(Wrapper.ZIP_STORE_BASE_PROPERTY),
       wrapper.getArchiveBase().toString());
   assertEquals(properties.getProperty(Wrapper.ZIP_STORE_PATH_PROPERTY), wrapper.getArchivePath());
 }
Esempio n. 14
0
    @Override
    protected Void doInBackground(final Void... unused) {

      Wrapper wrapper = new Wrapper();

      try {
        serverAddress = InetAddress.getByName(Constants.SERVER_IP);
        serverSocket = new Socket();
        serverSocket.connect(
            new InetSocketAddress(Constants.SERVER_IP, Constants.SERVER_PORT), 5000);
      } catch (Exception e) {
        e.printStackTrace();
      }

      wrapper.type = 0;
      wrapper.status = serverSocket.isConnected();
      publishProgress(wrapper);

      try {
        Thread.sleep(500);

        dataInputStream = new DataInputStream(serverSocket.getInputStream());
        dataOutputStream = new DataOutputStream(serverSocket.getOutputStream());

        wrapper.type = 1;

        while (serverSocket.isConnected()) {
          bytes = 0;

          size = dataInputStream.readInt();
          data = new byte[size];

          for (int i = 0; i < size; i += bytes) {
            bytes = dataInputStream.read(data, i, size - i);
          }

          buff = new Mat(1, size, CvType.CV_8UC1);
          buff.put(0, 0, data);

          rev = Highgui.imdecode(buff, Highgui.CV_LOAD_IMAGE_UNCHANGED);

          Imgproc.cvtColor(rev, ret, Imgproc.COLOR_RGB2BGR);

          wrapper.img = ret;
          publishProgress(wrapper);
          Thread.sleep(75);
        }

      } catch (Exception e) {
        e.printStackTrace();
      }

      return null;
    }
Esempio n. 15
0
 @Override
 public Void visitOp(PhysicalOperator op, Wrapper wrapper) {
   if (op instanceof HasAffinity) {
     wrapper.addEndpointAffinity(((HasAffinity) op).getOperatorAffinity());
   }
   Stats stats = wrapper.getStats();
   stats.addCost(op.getCost());
   for (PhysicalOperator child : op) {
     child.accept(this, wrapper);
   }
   return null;
 }
  @Override
  public FilterType join(List<Wrapper<FilterType>> items) {
    Wrapper<FilterType> filterTypeWrapper = findFistFromMannOtherwiseFirst(items);
    FilterType filterType = filterTypeWrapper.item();

    id++;
    FilterType newFilterType = new FilterType();
    newFilterType.setId(id);
    newFilterType.setCode(filterType.getCode());
    newFilterType.setName(filterType.getName());

    return newFilterType;
  }
Esempio n. 17
0
 /**
  * Return a method that casts its sole argument (an Object) to the given type and returns it as
  * the given type.
  */
 public static MethodHandle cast(Class<?> type) {
   if (type.isPrimitive())
     throw new IllegalArgumentException("cannot cast primitive type " + type);
   MethodHandle mh;
   Wrapper wrap = null;
   EnumMap<Wrapper, MethodHandle> cache = null;
   if (Wrapper.isWrapperType(type)) {
     wrap = Wrapper.forWrapperType(type);
     cache = WRAPPER_CASTS[0];
     mh = cache.get(wrap);
     if (mh != null) return mh;
   }
   mh = MethodHandles.insertArguments(CAST_REFERENCE, 0, type);
   if (cache != null) cache.put(wrap, mh);
   return mh;
 }
Esempio n. 18
0
 @Override
 public Void visitSendingExchange(Exchange exchange, Wrapper wrapper) throws RuntimeException {
   Stats stats = wrapper.getStats();
   stats.addCost(exchange.getAggregateSendCost());
   stats.addMaxWidth(exchange.getMaxSendWidth());
   return super.visitSendingExchange(exchange, wrapper);
 }
Esempio n. 19
0
 public boolean read(int i, Wrapper<ValueType> v) {
   if (isValid(i)) {
     v.object = A_[i];
     return true;
   }
   return false;
 }
Esempio n. 20
0
  /**
   * Called whenever the value of the selection changes.
   *
   * @param e the event that characterizes the change.
   */
  @Override
  public void valueChanged(final ListSelectionEvent e) {
    if (e.getValueIsAdjusting()) {
      return;
    } // ignore extra messages

    if (e.getSource() == table.getSelectionModel()) {
      int i = table.getSelectedRow();
      if (i >= 0) {
        Wrapper w = model.getWrapperAt(i);
        w.print = !w.print;
        model.fireTableRowsUpdated(i, i);
        table.clearSelection();
      }
    }
  }
Esempio n. 21
0
 private static MethodHandle unbox(Wrapper wrap, boolean cast) {
   EnumMap<Wrapper, MethodHandle> cache = UNBOX_CONVERSIONS[(cast ? 1 : 0)];
   MethodHandle mh = cache.get(wrap);
   if (mh != null) {
     return mh;
   }
   // slow path
   switch (wrap) {
     case OBJECT:
       mh = IDENTITY;
       break;
     case VOID:
       mh = IGNORE;
       break;
   }
   if (mh != null) {
     cache.put(wrap, mh);
     return mh;
   }
   // look up the method
   String name = "unbox" + wrap.wrapperSimpleName();
   MethodType type = unboxType(wrap);
   try {
     mh = IMPL_LOOKUP.findStatic(THIS_CLASS, name, type);
   } catch (ReflectiveOperationException ex) {
     mh = null;
   }
   if (mh != null) {
     mh = MethodHandles.insertArguments(mh, 1, cast);
     cache.put(wrap, mh);
     return mh;
   }
   throw new IllegalArgumentException(
       "cannot find unbox adapter for " + wrap + (cast ? " (cast)" : ""));
 }
Esempio n. 22
0
 @Test
 public void testWrapper() {
   wrapper = createTask(Wrapper.class);
   assertEquals("", wrapper.getJarPath());
   assertEquals("", wrapper.getScriptDestinationPath());
   assertEquals(Wrapper.DEFAULT_DISTRIBUTION_PARENT_NAME, wrapper.getDistributionPath());
   assertEquals(Wrapper.DEFAULT_ARCHIVE_NAME, wrapper.getArchiveName());
   assertEquals(Wrapper.DEFAULT_ARCHIVE_CLASSIFIER, wrapper.getArchiveClassifier());
   assertEquals(Wrapper.DEFAULT_DISTRIBUTION_PARENT_NAME, wrapper.getArchivePath());
   assertEquals(Wrapper.DEFAULT_URL_ROOT, wrapper.getUrlRoot());
   assertEquals(Wrapper.PathBase.GRADLE_USER_HOME, wrapper.getDistributionBase());
   assertEquals(Wrapper.PathBase.GRADLE_USER_HOME, wrapper.getArchiveBase());
 }
  public void testColumnMetadata() throws Exception {
    ColumnMetadata col = new ColumnMetadata("Billy", "employee", "comment");
    Wrapper w = new Wrapper();
    w.a = col;
    w.b = col;
    String json = MAPPER.writeValueAsString(w);

    Wrapper deserialized = MAPPER.readValue(json, Wrapper.class);
    assertNotNull(deserialized);
    assertNotNull(deserialized.a);
    assertNotNull(deserialized.b);

    assertEquals("Billy", deserialized.a.getName());
    assertEquals("employee", deserialized.a.getType());
    assertEquals("comment", deserialized.a.getComment());

    assertSame(deserialized.a, deserialized.b);
  }
Esempio n. 24
0
  public static void shutdown() {
    flush();

    if (Debug.ENABLED) ((Wrapper) _executor).shutdown();
    else {
      if (_executor instanceof ExecutorService) ((ExecutorService) _executor).shutdown();
    }

    _scheduler.shutdownNow();
  }
Esempio n. 25
0
  public static MethodHandle convertPrimitive(Wrapper wsrc, Wrapper wdst) {
    EnumMap<Wrapper, MethodHandle> cache = CONVERT_PRIMITIVE_FUNCTIONS[wsrc.ordinal()];
    MethodHandle mh = cache.get(wdst);
    if (mh != null) {
      return mh;
    }
    // slow path
    Class<?> src = wsrc.primitiveType();
    Class<?> dst = wdst.primitiveType();
    MethodType type =
        src == void.class ? MethodType.methodType(dst) : MethodType.methodType(dst, src);
    if (wsrc == wdst) {
      mh = identity(src);
    } else if (wsrc == Wrapper.VOID) {
      mh = zeroConstantFunction(wdst);
    } else if (wdst == Wrapper.VOID) {
      mh = MethodHandles.dropArguments(EMPTY, 0, src); // Defer back to MethodHandles.
    } else if (wsrc == Wrapper.OBJECT) {
      mh = unboxCast(dst);
    } else if (wdst == Wrapper.OBJECT) {
      mh = box(src);
    } else {
      assert (src.isPrimitive() && dst.isPrimitive());
      try {
        mh =
            IMPL_LOOKUP.findStatic(
                THIS_CLASS, src.getSimpleName() + "To" + capitalize(dst.getSimpleName()), type);
      } catch (ReflectiveOperationException ex) {
        mh = null;
      }
    }
    if (mh != null) {
      assert (mh.type() == type) : mh;
      cache.put(wdst, mh);
      return mh;
    }

    throw new IllegalArgumentException(
        "cannot find primitive conversion function for "
            + src.getSimpleName()
            + " -> "
            + dst.getSimpleName());
  }
  @Override
  public List<FilterType> merge(List<Wrapper<FilterType>> items) {
    Map<String /*businessKey*/, List<Wrapper<FilterType>>> keyMap =
        new HashMap<String, List<Wrapper<FilterType>>>();
    logger.trace("Merge for " + klass.getSimpleName());

    final List<FilterType> result = new ArrayList<FilterType>();

    // Groupping
    for (Wrapper<FilterType> item : items) {
      String businessKey = getBusinessKey(item);

      if (!keyMap.containsKey(businessKey)) {
        keyMap.put(businessKey, new ArrayList<Wrapper<FilterType>>());
      }

      keyMap.get(businessKey).add(item);
    }

    // Joining
    int counter = 0;
    for (Map.Entry<String, List<Wrapper<FilterType>>> item : keyMap.entrySet()) {
      counter++;
      if (counter % 100 == 0)
        logger.debug("Processing " + klass + " " + counter + " of " + keyMap.size());

      String businessKey = item.getKey();
      List<Wrapper<FilterType>> itemsToJoin = item.getValue();

      FilterType newItem = join(itemsToJoin);
      finalTemplate.save(newItem);
      for (Wrapper<FilterType> itemToJoin : itemsToJoin) {
        addToContext(itemToJoin.source(), itemToJoin.item().getCode(), newItem.getCode());
      }

      mergeChildren(itemsToJoin);
      result.add(newItem);
    }

    return result;
  }
Esempio n. 27
0
 @Before
 public void setUp() {
   super.setUp();
   context.setImposteriser(ClassImposteriser.INSTANCE);
   wrapper = createTask(Wrapper.class);
   wrapperScriptGeneratorMock = context.mock(WrapperScriptGenerator.class);
   wrapper.setScriptDestinationPath("scriptDestination");
   wrapper.setGradleVersion("1.0");
   targetWrapperJarPath = "jarPath";
   expectedTargetWrapperJar =
       new TestFile(
           getProject().getProjectDir(), targetWrapperJarPath + "/" + Wrapper.WRAPPER_JAR);
   expectedTargetWrapperProperties =
       new File(
           getProject().getProjectDir(), targetWrapperJarPath + "/" + Wrapper.WRAPPER_PROPERTIES);
   new File(getProject().getProjectDir(), targetWrapperJarPath).mkdirs();
   distributionPath = "somepath";
   wrapper.setJarPath(targetWrapperJarPath);
   wrapper.setDistributionPath(distributionPath);
   wrapper.setUnixWrapperScriptGenerator(wrapperScriptGeneratorMock);
 }
Esempio n. 28
0
  public static void flush() {
    if (Debug.ENABLED) ((Wrapper) _executor).flush();
    else {
      ThreadPoolExecutor executor = (ThreadPoolExecutor) _executor;

      while (executor.getQueue().size() > 0 || executor.getActiveCount() > 0) {
        try {
          Thread.sleep(1);
        } catch (InterruptedException e) {
        }
      }
    }
  }
Esempio n. 29
0
 /**
  * Produce a Number which represents the given value {@code x} according to the primitive type of
  * the given wrapper {@code wrap}. Caller must invoke intValue, byteValue, longValue (etc.) on the
  * result to retrieve the desired primitive value.
  */
 public static Number primitiveConversion(Wrapper wrap, Object x, boolean cast) {
   // Maybe merge this code with Wrapper.convert/cast.
   Number res;
   if (x == null) {
     if (!cast) return null;
     return ZERO_INT;
   }
   if (x instanceof Number) {
     res = (Number) x;
   } else if (x instanceof Boolean) {
     res = ((boolean) x ? ONE_INT : ZERO_INT);
   } else if (x instanceof Character) {
     res = (int) (char) x;
   } else {
     // this will fail with the required ClassCastException:
     res = (Number) x;
   }
   Wrapper xwrap = Wrapper.findWrapperType(x.getClass());
   if (xwrap == null || !cast && !wrap.isConvertibleFrom(xwrap))
     // this will fail with the required ClassCastException:
     return (Number) wrap.wrapperType().cast(x);
   return res;
 }
  private void assignEndpoints(
      Collection<DrillbitEndpoint> allNodes,
      PlanningSet planningSet,
      int globalMaxWidth,
      int maxWidthPerEndpoint)
      throws PhysicalOperatorSetupException {
    // First we determine the amount of parallelization for a fragment. This will be between 1 and
    // maxWidth based on
    // cost. (Later could also be based on cluster operation.) then we decide endpoints based on
    // affinity (later this
    // could be based on endpoint load)
    for (Wrapper wrapper : planningSet) {

      Stats stats = wrapper.getStats();

      // figure out width.
      int width = Math.min(stats.getMaxWidth(), globalMaxWidth);
      float diskCost = stats.getDiskCost();
      //      logger.debug("Frag max width: {} and diskCost: {}", stats.getMaxWidth(), diskCost);

      // TODO: right now we'll just assume that each task is cost 1 so we'll set the breadth at the
      // lesser of the number
      // of tasks or the maximum width of the fragment.
      if (diskCost < width) {
        //        width = (int) diskCost;
      }

      width = Math.min(width, maxWidthPerEndpoint * allNodes.size());

      if (width < 1) width = 1;
      //      logger.debug("Setting width {} on fragment {}", width, wrapper);
      wrapper.setWidth(width);
      // figure out endpoint assignments. also informs the exchanges about their respective
      // endpoints.
      wrapper.assignEndpoints(allNodes);
    }
  }