Starting a service only after another one is completely started (on CentOS)

492

It looks like your startup service is named postgresql not postgresql-9.1

Try this out in netnfork:

# Required-Start: network postgresql
Share:
492

Related videos on Youtube

artaxerxe
Author by

artaxerxe

Updated on September 18, 2022

Comments

  • artaxerxe
    artaxerxe almost 2 years

    I am currently trying to implement interpolation search with floating numbers, here is my code:

    import java.util.Arrays;
    
    class InterpolationSearch   {
        private static float comparisions = 0;
        public static int interpolationsearch (double arr[], double x, int high, int low)   {
        while ( low<=high)  {
            comparisions++;
            int i = low + (x-arr[low])*(high-low)/(arr[high]-arr[low]);
            if (x==arr[i])
                return i;
            else if (x<arr[i])   
                high = i-1;
            else
                low = i+1;
            }
            return -1;
        }   
        public static void main(String args[])  {
            int n=100;
            double array[] = new double[n];
            for (int i=0; i<100; i++)   {
                for (int k=0; k<n; k++) {
                    double r = Math.random();
                    r = r * 100;
                    r = Math.round(r);
                    r = r / 100;
                    array[k] = r;
                }
                Arrays.sort(array);
                double search = Math.random();
                search = search*100;
                search = Math.round(search);
                search = search/100;
                int result=interpolationsearch(array, search, n-1, 0);
                if (result == -1)
                    System.out.println(search +" befindet sich nicht im Array.");
                else
                    System.out.println(search+" befindet sich im Array an der Stelle "+(result)+".");
            }
            System.out.println("Anzahl der gemittelten Vergleiche: "+comparisions/100+".");
        }
    }
    

    First of all is my algorithm correct? Second how do I get this working with floating numbers? In the current code I get the following error at line 8: Type mismatch: cannot convert from double to int. I already tried to cast everything to int, but it did not work.

    • ewwhite
      ewwhite over 11 years
      In a pinch, I'd just manage both daemons with Monit. But that's not a clean fix.
  • Admin
    Admin about 7 years
    That is exactly what I did, but it doesn't work at all. It works for like 2 loops and then the program stops working for no reason, so this should not be the best solution, even though it should theoretically work... The question is why is it working for you but not for me? The output seems to be correct, yes.